Here you can find the source of getLastId(PreparedStatement s)
public static Integer getLastId(PreparedStatement s) throws SQLException
//package com.java2s; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; public class Main { public static Integer getLastId(PreparedStatement s) throws SQLException { if (s == null) return null; ResultSet rs = s.getGeneratedKeys(); if (!rs.next()) return null; return rs.getInt(1); }// w w w .ja va2 s . c o m }