Here you can find the source of getGenerateKey(PreparedStatement stmt)
public static int getGenerateKey(PreparedStatement stmt) throws SQLException
//package com.java2s; //License from project: Open Source License import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; public class Main { public static int getGenerateKey(PreparedStatement stmt) throws SQLException { int key = 0; // recuperar a chave ResultSet rs = stmt.getGeneratedKeys(); // recuperar a chave como inteiro if (rs.next()) { key = rs.getInt(1);/*from w w w. j av a 2 s . co m*/ } return key; } }