Foros del Web » Programación para mayores de 30 ;) » Java »

Error con Java y POstgresql

Estas en el tema de Error con Java y POstgresql en el foro de Java en Foros del Web. Buenas Amigos Al Querer Ejecutar mi Aplicacion Me genera este error= org.postgresql.util.PSQLException: ResultSet not positioned properly, perhaps you need to call next. Quisiera Saber por ...
  #1 (permalink)  
Antiguo 10/05/2011, 15:54
Avatar de HaroldV  
Fecha de Ingreso: enero-2010
Ubicación: Maracaibo
Mensajes: 100
Antigüedad: 14 años, 3 meses
Puntos: 3
Error con Java y POstgresql

Buenas Amigos Al Querer Ejecutar mi Aplicacion Me genera este error= org.postgresql.util.PSQLException: ResultSet not positioned properly, perhaps you need to call next.

Quisiera Saber por que Aqui esta el Codigo q ejecuto

Código:
 for(dia=1;dia<=31;dia++,j++){

                          String fechaCompleta = year+"/"+mes+"/"+dia;
                          System.out.println("BIEN");
                          query2 = "Select fkxc,valork,valorc,valord, Max(greatest(hora0430_0530,hora0530_0630,hora0630_0730,hora0730_0830,"+
                                   "hora0830_0930,hora0930_1030,hora1030_1130,hora1130_1230,"+
                                   "hora1230_1330,hora1330_1430,hora1430_1530,hora1530_1630,"+
                                   "hora1630_1730,hora1730_1830,hora1830_1930)) As ValorMax FROM "+" "+elemento+ " WHERE fecha= ? and estacion= ? group by fkxc,valork,valorc,valord";

                          pst =  prepararConsulta(query2);
                          pst.setString(1, fechaCompleta);
                          pst.setString(2, estacion);
                          
                          rst = pst.executeQuery();
                          
                          rst.next();                          

                          fkxc   = rst.getDouble("fkxc");
                          valork = rst.getInt("valork");
                          valorc = rst.getDouble("valorc");
                          valord = rst.getDouble("valord");
                          cad    = rst.getDouble("ValorMax");


                                System.out.println(cad);
                                System.out.println(fkxc);
                                System.out.println("C:"+valorc);
                                System.out.println("D:"+valord);
                                System.out.println("K:"+valork);
                                System.out.println(fechaCompleta);
                                System.out.println(estacion);


                          
                          tablaDiarios.setValueAt(fkxc, i, 3);
                          tablaDiarios.setValueAt(valork, i, 4);
                          tablaDiarios.setValueAt(valorc, i, 5);
                          tablaDiarios.setValueAt(valord, i, 6);
                          tablaDiarios.setValueAt(cad, i, j);
De antemano doy las Gracias Aquella persona que pueda Aportar algo =)
  #2 (permalink)  
Antiguo 12/05/2011, 01:21
Avatar de chuidiang
Colaborador
 
Fecha de Ingreso: octubre-2004
Mensajes: 3.774
Antigüedad: 19 años, 7 meses
Puntos: 454
Respuesta: Error con Java y POstgresql

Es posible que no hay resultados y rst.next() no de nada. Lo habitual es hacer

Código java:
Ver original
  1. while (rst.next()) {
  2. ...
  3. }

o si solo quieres coger un resultado

Código java:
Ver original
  1. if (rst.next()) {
  2. ...
  3. }

ya que rst.next() devuelve true o false según haya o no resultados y debe comprobarse de alguna manera.

Se bueno.
__________________
Apuntes Java
Wiki de Programación

Etiquetas: postgresql
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:54.