aphex.twin Posted July 18, 2012 Report Share Posted July 18, 2012 Hola:Tengo el siguiente problema, estoy realizando un programa en netbeans para conectar una base de datos en mysql y realizar las consultas. El problema es que en un método llamado BuscarRunPaciente me tira error, ya que según netbeans los parámetros que le estoy pasando para Run_paciente no son correctos. Ya revise varias veces el código y no encuentro donde esta el error. Espero me puedan ayudar.Saludos.Aquí el código de los métodos que utilizo /*metodo para cargar datos mediante busqueda del run del paciente*/ public void cargarRunPaciente(){ try{ Conexion.buscaRunPaci=false; Conexion conec = new Conexion(); String sql = "select * from cliente where run_paciente="+run_paciente+""; objConexion = conec.abrirConeccionBd(usuario, clave); Conexion.sentencia=objConexion.prepareStatement(sql); ResultSet objRes = Conexion.sentencia.executeQuery(sql); if(objRes.next()){ Conexion.buscaRunPaci=true; run_paciente=Integer.parseInt(objRes.getString(1)); nombre = objRes.getString(2); apel_paterno = objRes.getString(3); apel_materno = objRes.getString(4); fono= Integer.parseInt(objRes.getString(5)); }else{ Conexion.buscaRunPaci=false; //JOptionPane.showMessageDialog(null,"Dato no existe","RUN",2); } }catch(Exception e){ System.out.println("fallo metodo buscar"); } } /*metodo para buscar paciente mediante su run, pero mediante GUI*/ private void jbtnBuscarActionPerformed(java.awt.event.ActionEvent evt) { try{ Paciente objPaci = new Paciente(Integer.parseInt(jtxt_run_edicion.getText()),"ass","fddf",1313);/*---->Aqui el error y wea*/ objPaci.cargarRunPaciente(); if(Conexion.buscaRunPaci){ jtxt_nombre_edicion.setText(objPaci.nombre); jtxt_apel_paterno_edicion.setText(objPaci.apel_paterno); jtxt_apel_materno_edicion.setText(objPaci.apel_materno); jtxt_fono_edicion.setText(String.valueOf(objPaci.fono)); }else{ JOptionPane.showMessageDialog(this,"Cliente no existe","Buscar",2); } objPaci=null; } catch(Exception e){ } Link to comment Share on other sites More sharing options...
AshWilliams Posted July 19, 2012 Report Share Posted July 19, 2012 Si el error es en la línea que indicas, pues, eso significa que los parámetros que estas pasándole al constructor son incorrectos, asi que ojo ;) PS: String sql = "select * from cliente where run_paciente="+run_paciente+""; que valor toma run_paciente??????????????Saludos :krider: Link to comment Share on other sites More sharing options...
ToroNegro Posted July 20, 2012 Report Share Posted July 20, 2012 Hola, fijate también en esta línea String sql = "select * from cliente where run_paciente="+run_paciente+"";La consulta deberia ser con comilla simple String sql = "select * from cliente where run_paciente='+run_paciente+'"; Link to comment Share on other sites More sharing options...
SnK_roak Posted July 25, 2012 Report Share Posted July 25, 2012 run_paciente.getText() o tiene algun valor antes? ... Link to comment Share on other sites More sharing options...
egozcl Posted July 26, 2012 Report Share Posted July 26, 2012 tu problema esta en el metodo constructor de la clase paciente, segun lo que dices tu en el segundo codigo Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now