tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 iBATIS > Basics > Get Record Count

Get Record Count 

The following example shows getting student record count.

File Name  :  
/IBATIS001/config/basic/Count.xml 

File Name  :  
com/bethecoder/tutorials/ibatis/tests/basic/Count.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
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[] argsthrows IOException, SQLException {

    Reader reader = Resources.getResourceAsReader("SqlMapConfig.xml");
    SqlMapClient sqlMapClent = SqlMapClientBuilder.buildSqlMapClient(reader);

    Integer studentCount = (IntegersqlMapClent.queryForObject("Student.count");
    System.out.println("Total student count : " + studentCount);
    
  }
}
   

It gives the following output,
Total student count : 5



 
  


  
bl  br