public class TestaConexao { public static void main(String[] args) SQLException {
Conexao com = new Conexao(); Connection conexao = com.getConexao();
Statement stmt = conexao.createStatement(); boolean resultado = stmt.execute("Insert into produto (id,nome) Values (null,'roger')", stmt.RETURN_GENERATED_KEYS);
ResultSet res = stmt.getGeneratedKeys();
while (res.next()) {
String id = res.getString("id"); System.out.println(id);
}
conexao.close();
}
}