public int ejecuta_query(String Query) {
PreparedStatement pstmt;
int key = 0;
try {
pstmt = conn.prepareStatement(Query,
Statement.RETURN_GENERATED_KEYS);
pstmt.executeUpdate();
ResultSet keys = pstmt.getGeneratedKeys();
keys.next();
key = keys.getInt(1);
keys.close();
pstmt.close();
conn.close();
} catch (Exception e) { e.printStackTrace(); }
return key;
} |
public int ejecuta_query(String Query) {
PreparedStatement pstmt;
int key = 0;
try {
pstmt = conn.prepareStatement(Query,
Statement.RETURN_GENERATED_KEYS);
pstmt.executeUpdate();
ResultSet keys = pstmt.getGeneratedKeys();
keys.next();
key = keys.getInt(1);
keys.close();
pstmt.close();
conn.close();
} catch (Exception e) { e.printStackTrace(); }
return key;
}