Skip to content

Instantly share code, notes, and snippets.

@cemo
Created July 8, 2013 10:46
Show Gist options
  • Select an option

  • Save cemo/5947838 to your computer and use it in GitHub Desktop.

Select an option

Save cemo/5947838 to your computer and use it in GitHub Desktop.
protected long getGeneratedLongKey(PreparedStatement stmt) throws SQLException {
ResultSet rs = null;
long result = 0;
try {
rs = stmt.executeQuery("SELECT @@IDENTITY");
rs.next();
result = rs.getLong(1);
} finally {
if (rs != null)
rs.close();
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment