Here you can find the source of getMaxID()
public static int getMaxID() throws SQLException
//package com.java2s; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Main { static String JDBC_URL = "jdbc:mysql://localhost/rssminer?cachePrepStmts=true&useServerPrepStmts=true"; public static int getMaxID() throws SQLException { Connection con = getRssminerDB(); Statement stat = con.createStatement(); ResultSet rs = stat.executeQuery("select max(id) from feed_data"); rs.next();//from w w w . j ava2 s . c o m int max = rs.getInt(1); con.close(); return max; } public static Connection getRssminerDB() throws SQLException { Connection con = DriverManager.getConnection(JDBC_URL, "feng", ""); return con; } }