Mysql autonumeracao

1 resposta
C

tenho um campo autonumber e preciso quando faco o insert
recuperar o valor deste campo

1 Resposta

J
PreparedStatement stmt = conexao.prepareStatement("insert into tabela (nome) values(?)");

stmt.setString(1, "Jair");

stmt.executeUpdate();

ResultSet res = stmt.getGeneratedKeys();

res.first();

int id = res.getInt(1);
Criado 24 de julho de 2006
Ultima resposta 24 de jul. de 2006
Respostas 1
Participantes 2