Problemas en consulta
Publicado por EfrainMejiasC (9 intervenciones) el 19/09/2012 02:54:06
Hola
Realizo una consulta y solo me muestra el id no muestra los otros campos...???
este es el metodo que ejecuto:
public void MetodoBuscar(String nombre) throws ClassNotFoundException, SQLException
{
this.nombre=nombre;
try{
Class.forName(driver);
Connection conexion = DriverManager.getConnection(url+db,user,pass);
Statement instruccion = conexion.createStatement();
ResultSet tabla = instruccion.executeQuery("SELECT id , Nombre , Sueldo FROM contactos");
while (tabla.next()) {
System.out.println("ID : "+ tabla.getInt(1));
System.out.println("NOMBRE : "+ tabla.getString(2));
System.out.println("SUELDO : "+ tabla.getString(3));
System.out.println(" ");
}
}catch(ClassNotFoundException e){ System.out.println(e); }
catch(SQLException e){ System.out.println(e); }
catch(Exception e){ System.out.println(e); }
}
Y la salida es esta :
ID : 1
NOMBRE :
APELLIDO:
ID : 2
NOMBRE :
APELLIDO:
ID : 3
NOMBRE :
APELLIDO:
Q Estara pasando??? los registros existen ya lo verifique..
Realizo una consulta y solo me muestra el id no muestra los otros campos...???
este es el metodo que ejecuto:
public void MetodoBuscar(String nombre) throws ClassNotFoundException, SQLException
{
this.nombre=nombre;
try{
Class.forName(driver);
Connection conexion = DriverManager.getConnection(url+db,user,pass);
Statement instruccion = conexion.createStatement();
ResultSet tabla = instruccion.executeQuery("SELECT id , Nombre , Sueldo FROM contactos");
while (tabla.next()) {
System.out.println("ID : "+ tabla.getInt(1));
System.out.println("NOMBRE : "+ tabla.getString(2));
System.out.println("SUELDO : "+ tabla.getString(3));
System.out.println(" ");
}
}catch(ClassNotFoundException e){ System.out.println(e); }
catch(SQLException e){ System.out.println(e); }
catch(Exception e){ System.out.println(e); }
}
Y la salida es esta :
ID : 1
NOMBRE :
APELLIDO:
ID : 2
NOMBRE :
APELLIDO:
ID : 3
NOMBRE :
APELLIDO:
Q Estara pasando??? los registros existen ya lo verifique..
Valora esta pregunta


0