Here you can find the source of generateKey(Statement statement, String TableName, String KeyColumn)
public static int generateKey(Statement statement, String TableName, String KeyColumn) throws SQLException
//package com.java2s; //License from project: Apache License import java.sql.*; public class Main { public static int generateKey(Statement statement, String TableName, String KeyColumn) throws SQLException { String sql = "SELECT MAX(" + KeyColumn + ") FROM " + TableName; return getQueryInt(statement, sql); }//from w ww . jav a 2 s . c om public static int getQueryInt(Statement statement, String pSql) throws SQLException { ResultSet rs = statement.executeQuery(pSql); int ret = 0; if (!rs.next()) return (1); return (rs.getInt(1)); } }