Here you can find the source of getIdNumber(String tableName)
public static int getIdNumber(String tableName)
//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 { private static Connection connection = null; public static int getIdNumber(String tableName) { try {/* w w w.j a v a 2 s .c om*/ Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM " + tableName); int count = 0; while (rs.next()) { count++; } return count + 1; } catch (SQLException e) { System.out.println("Connection Failed! Check output console"); e.printStackTrace(); return -1; } } }