come posso ottenere l'ultimo id inserito in una tabella? so che c'è una funzione mysql per last_insert_id ma mi ritorna sempre 0
grazie ciao
come posso ottenere l'ultimo id inserito in una tabella? so che c'è una funzione mysql per last_insert_id ma mi ritorna sempre 0
grazie ciao
ho risolto
a chi potesse interessare:
try {
....
stmt = conn.createStatement();
sql = "insert into .....";
int i = stmt.executeUpdate(sql,Statement.RETURN_GENERATED_ KEYS);
rs = stmt.getGeneratedKeys();
while (rs.next()){
idUtente = rs.getInt(1);
....
}
}
catch (SQLException e) {.....}