필드 중 하나가 자동 증가 (id)되는 테이블의 코드를 사용하여 레코드를 삽입하십시오. 방금 삽입 한 레코드의 autoincremented field (id) 값을 어떻게 알 수 있습니까?자동 증가 필드의 값 알기
PreparedStatement ps = null;
Connection con = null;
ResultSet rs = null;
int rows = 0;
try {
String SQL_DRV = "org.hsqldb.jdbcDriver";
String SQL_URL = "jdbc:hsqldb:hsql://localhost/localDB";
Class.forName(SQL_DRV);
con = DriverManager.getConnection(SQL_URL, "sa", "");
ps = con.prepareStatement(
"insert into infousuarios (nombre, apellidos, email) " +
"values (?, ?, ?)");
ps.setString(1, name);
ps.setString(2, surnames);
ps.setString(3, login+"@micorreo.com");
rows = ps.executeUpdate();
// How I can know the value of autoincrement field (id) of the record just enter??
대부분의 데이터베이스에 대한 호출은 일반적으로 뭔가 "마지막으로 삽입 ID가"또는 같은를 검색하는 기능을 가지고있다. – Erik
이 대답보기 http://stackoverflow.com/questions/10353405/how-to-return-last-inserted-auto-incremented-row-id-in-hsql –
해결되었습니다. 감사합니다 @SemyonSadetsky – user3764379