Tema: JAVA y SQL
Ver Mensaje Individual
  #9 (permalink)  
Antiguo 24/11/2005, 11:34
OrionKing
 
Fecha de Ingreso: agosto-2005
Mensajes: 142
Antigüedad: 18 años, 9 meses
Puntos: 0
DIOOOOOSSSS!!!!! que torpe he vuelto a copy pastear maaaaallll!!!!!


Si que lo tenia puesto pero me da 0
try{...
conn = DriverManager.getConnection (url, user, pass);
Statement stmt = conn.createStatement() ;
retorno=stmt.executeUpdate(query) ;
PreparedStatement SlastID = conn.prepareStatement("SELECT LAST_INSERT_ID() ");
System.out.println("LLega aqui conn ");
ResultSet lastID = SlastID.executeQuery();
System.out.println("LLega aqui resultset ");

while (lastID.next()){
questionID = lastID.getInt(1);
System.out.println("entroooo ");
}

System.out.println("LLega aqui ");
System.out.println("ulti "+ questionID);
stmt.close();
conn.close();
}catch (SQLException ex) {
System.out.println("ERROR en consulta SQL.");
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());

} catch (ClassNotFoundException e){

System.out.println("error :(");

}
return retorno;

Ya no se que mirar