Here you can find the source of count(Connection conn, String table)
public static long count(Connection conn, String table)
//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 long count(Connection conn, String table) { long ret = 0; try {//from w ww . j a v a 2s . c om Statement statement = conn.createStatement(); String sql = String.format("select count(*) from %s;", table); ResultSet set = statement.executeQuery(sql); if (set.next()) { ret = set.getLong(1); } statement.close(); } catch (SQLException e) { e.printStackTrace(); } return ret; } }