Here you can find the source of getCount(Connection conn, String tableName)
public static int getCount(Connection conn, String tableName) throws SQLException
//package com.java2s; //License from project: Open Source License import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Main { public static int getCount(Connection conn, String tableName) throws SQLException { String sql = "select count(*) from " + tableName; Statement stmt = conn.createStatement(); ResultSet rset = stmt.executeQuery(sql); rset.next();//w w w .ja va 2s. co m int count = rset.getInt(1); rset.close(); stmt.close(); return count; } }