Código HTML:
String g="Select usuario_id from usuarios where usuario_id='100'";
String val="";
Statement stmt = conn.createStatement ();
val = stmt.executeQuery(g).getString("usuario_id");
|
|
#1 (permalink) |
![]() Fecha de Ingreso: septiembre-2005
Mensajes: 960
|
Código HTML:
String g="Select usuario_id from usuarios where usuario_id='100'";
String val="";
Statement stmt = conn.createStatement ();
val = stmt.executeQuery(g).getString("usuario_id");
__________________
Wow! No se que decir... |
|
|
|
|
|
#2 (permalink) |
![]() Fecha de Ingreso: abril-2008
Mensajes: 11
|
Re: Ayuda con un ResulSet
Intenta asi:
String val=""; Statement stmt = conn.createStatement (); ResultSet results = stmt.executeQuery("Select usuario_id from usuarios where usuario_id='100'"); if (results.next()) val = results.getString("usuario_id"); System.out.print("valor=>"+val); saludos. |
|
|
|
|
|
#4 (permalink) |
![]() |
Re: Ayuda con un ResulSet
la conficion if(results.next()) coloca el apuntador asi el registro en contrado, el compilador al momento de encontraro devuelve un true sino un false, si devuelve el true guarda el valor en val por ejemplo supon que quieres hacer una consulta pero te regresa varios registros no solo uno puedes usar while(results.next()) y con eso recorres todos los registros.
|
|
|
|
|
|
#5 (permalink) |
![]() Fecha de Ingreso: marzo-2008
Mensajes: 3
|
Re: Ayuda con un ResulSet
Cita:
Lo que no entiendo, para que quieres el usuario_id si en el where le estas diciendo que usuario_id necesitas. o.o?
Iniciado por zyon
Que tal amigos, estoy intentando ejecutar un select y obtener un campo asi:
Código HTML:
String g="Select usuario_id from usuarios where usuario_id='100'";
String val="";
Statement stmt = conn.createStatement ();
val = stmt.executeQuery(g).getString("usuario_id");
|
|
|
|