In Java, how to get the value of an autoincrement column after inserting a row into a table:
try
{
Statement myStmt = (Statement)connection.createStatement();
myStmt.executeUpdate(sqlStmt, Statement.RETURN_GENERATED_KEYS);
ResultSet rs = myStmt.getGeneratedKeys();
rs.next();
answer = rs.getInt(1);
} // end try
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment