|
Get Record Count
The following example shows getting student record count.
|
package com.bethecoder.tutorials.ibatis.tests.basic;
import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
public class Count {
/**
* @param args
* @throws IOException
* @throws SQLException
*/
public static void main(String[] args) throws IOException, SQLException {
Reader reader = Resources.getResourceAsReader("SqlMapConfig.xml");
SqlMapClient sqlMapClent = SqlMapClientBuilder.buildSqlMapClient(reader);
Integer studentCount = (Integer) sqlMapClent.queryForObject("Student.count");
System.out.println("Total student count : " + studentCount);
}
}
|
| |
It gives the following output,
Total student count : 5
|
|