I have a Statement
where I insert some values to a table in my database, this table has a primary key which is identity it's name is : numBon
.
When I execute the insert command, I want to get the value of numBon
.
for now I'm working with this code :
Statement st = connection.createStatement();
ResultSet result = st.executeQuery("SELECT MAX(numBon) FROM BonInterne");
int numBon;
if (result.next()) {
numBon = result.getInt("numBon");
}
Isn't there any other way ?