SQL query not executing in java -


im trying execute query through java program doesn't execute. here's method

 public list<usuario> darproveedores() throws exception{     preparedstatement st=null;     arraylist<usuario> respuesta = new arraylist<usuario>();     string consulta ="select u.direccion_electronica dire, "                     + "u.login login, "                     + "u.palabra_clave clave, "                     + "u.rol rol, "                     + "u.tipo_persona tipoper, "                     + "u.documento_identificacion docid, "                     + "u.nombre nombre, "                     + "u.nacionalidad naci, "                     + "u.direccion_fisica dirf, "                     + "u.telefono tel, "                     + "u.ciudad ciudad, "                     + "u.departamento depto, "                     + "u.codigo_postal codpostal "                     + " usuarios u "                     + " u.rol='proveedor' ";     try{          initemp();         establecerconexion(cadenaconexion, usuario, clave);         st = conexion.preparestatement(consulta);         resultset r= st.executequery(consulta);          while(r.next()){              string dire= r.getstring("dire");             string login = r.getstring("login");             string clave = r.getstring("clave");             string rol = r.getstring("rol");             string tipoper = r.getstring("tipoper");             string docid = r.getstring("docid");             string nombre = r.getstring("nombre");             string naci = r.getstring("naci");             string dirf = r.getstring("dirf");             string tel= r.getstring("tel");             string ciudad = r.getstring("ciudad");             string depto = r.getstring("depto");             string codpostal = r.getstring("codpostal");              usuario u = new usuario(login, dire, clave, rol, tipoper, integer.parseint(docid), nombre, naci, dirf, integer.parseint(tel), ciudad, depto, integer.parseint(codpostal));              respuesta.add(u);         }      }     catch(exception e)     {         e.printstacktrace();      }      finally{         if (st != null)          {             try {                 st.close();             } catch (sqlexception exception) {                  throw new exception("error: consultadao: loadrow() =  cerrando una conexion.");             }         }         closeconnection(conexion);     }      return respuesta; } 

i have executed query on sql developer , returns table values, when through here while(r.next()) instruction says there no rows in answer

you don't need use preparedstatement when there no parameters. use statement in place of preparedstatement, , st = conexion.createstatement() create it.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -