java - JSP returns NullPointerException when doing Select Query -


stack trace:

    >advertencia:   web application [/rian_solutions] registered jdbc driver [com.mysql.jdbc.driver] failed unregister when web application stopped. prevent memory leak, jdbc driver has been forcibly unregistered. información:   visiting unvisited references grave:   pwc6117: file "null" not found información:   visiting unvisited references información:   visiting unvisited references información:   visiting unvisited references información:   loading application [rian_solutions] @ [/rian_solutions] información:   rian_solutions deployed in 1.161 milliseconds. grave:   thu sep 01 16:48:56 cdt 2016 warn: establishing ssl connection without server's identity verification not recommended. according mysql 5.5.45+, 5.6.26+ , 5.7.6+ requirements ssl connection must established default if explicit option isn't set. compliance existing applications not using ssl verifyservercertificate property set 'false'. need either explicitly disable ssl setting usessl=false, or set usessl=true , provide truststore server certificate verification. advertencia:   standardwrappervalve[jsp]: servlet.service() servlet jsp threw exception java.lang.nullpointerexception @ java.lang.string$caseinsensitivecomparator.compare(string.java:1192) @ java.lang.string$caseinsensitivecomparator.compare(string.java:1186) @ java.util.treemap.getentryusingcomparator(treemap.java:376) @ java.util.treemap.getentry(treemap.java:345) @ java.util.treemap.get(treemap.java:278) @ com.mysql.jdbc.resultsetimpl.findcolumn(resultsetimpl.java:1051) @ com.mysql.jdbc.resultsetimpl.getstring(resultsetimpl.java:5202) @ org.apache.jsp.consulta_jsp._jspservice(consulta_jsp.java:74) @ org.apache.jasper.runtime.httpjspbase.service(httpjspbase.java:111) @ javax.servlet.http.httpservlet.service(httpservlet.java:790) @ org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:411) @ org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:473) @ org.apache.jasper.servlet.jspservlet.service(jspservlet.java:377) @ javax.servlet.http.httpservlet.service(httpservlet.java:790) @ org.apache.catalina.core.standardwrapper.service(standardwrapper.java:1682) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:318) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:160) @ org.apache.catalina.core.standardpipeline.doinvoke(standardpipeline.java:734) @ org.apache.catalina.core.standardpipeline.invoke(standardpipeline.java:673) @ com.sun.enterprise.web.webpipeline.invoke(webpipeline.java:99) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:174) @ org.apache.catalina.connector.coyoteadapter.doservice(coyoteadapter.java:416) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:283) @ com.sun.enterprise.v3.services.impl.containermapper$httphandlercallable.call(containermapper.java:459) @ com.sun.enterprise.v3.services.impl.containermapper.service(containermapper.java:167) @ org.glassfish.grizzly.http.server.httphandler.runservice(httphandler.java:206) @ org.glassfish.grizzly.http.server.httphandler.dohandle(httphandler.java:180) @ org.glassfish.grizzly.http.server.httpserverfilter.handleread(httpserverfilter.java:235) @ org.glassfish.grizzly.filterchain.executorresolver$9.execute(executorresolver.java:119) @ org.glassfish.grizzly.filterchain.defaultfilterchain.executefilter(defaultfilterchain.java:283) @ org.glassfish.grizzly.filterchain.defaultfilterchain.executechainpart(defaultfilterchain.java:200) @ org.glassfish.grizzly.filterchain.defaultfilterchain.execute(defaultfilterchain.java:132) @ org.glassfish.grizzly.filterchain.defaultfilterchain.process(defaultfilterchain.java:111) @ org.glassfish.grizzly.processorexecutor.execute(processorexecutor.java:77) @ org.glassfish.grizzly.nio.transport.tcpniotransport.fireioevent(tcpniotransport.java:536) @ org.glassfish.grizzly.strategies.abstractiostrategy.fireioevent(abstractiostrategy.java:112) @ org.glassfish.grizzly.strategies.workerthreadiostrategy.run0(workerthreadiostrategy.java:117) @ org.glassfish.grizzly.strategies.workerthreadiostrategy.access$100(workerthreadiostrategy.java:56) @ org.glassfish.grizzly.strategies.workerthreadiostrategy$workerthreadrunnable.run(workerthreadiostrategy.java:137) @ org.glassfish.grizzly.threadpool.abstractthreadpool$worker.dowork(abstractthreadpool.java:591) @ org.glassfish.grizzly.threadpool.abstractthreadpool$worker.run(abstractthreadpool.java:571) @ java.lang.thread.run(thread.java:745)` 

here's code:

package servlet;  import java.io.ioexception; import java.io.printwriter; import java.sql.*; import javax.servlet.servletconfig; import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse;  @webservlet(name = "consulta", urlpatterns = {"/consulta"}) public class consulta extends httpservlet {  @override public void init(servletconfig conf) throws servletexception { super.init(conf); }      protected void processrequest(httpservletrequest request,   httpservletresponse response) throws servletexception, ioexception {     response.setcontenttype("text/html;charset=utf-8");     printwriter out = response.getwriter();     connection conexion = null;         try {     class.forname("com.mysql.jdbc.driver"); conexion = drivermanager.getconnection     ("jdbc:mysql://127.0.0.1:3306/bdcuentas", "root","toor");     string folio=request.getparameter("folio");     string query=("select    num_folio,cuenta,nombre,apellido_pat,apellido_mat,direccion,telefono,edad  contribuyente num_folio="+folio+"");     statement stmt = conexion.createstatement(                        resultset.type_scroll_insensitive,                        resultset.concur_read_only);     resultset rs = stmt.executequery(query);                 if(rs != null) {     while(rs.next())      {         string num_folio = rs.getstring("num_folio");            out.println("el numero de folio es:" + num_folio );          string cuenta = rs.getstring("cuenta");            out.println("el numero de cuenta es:" + cuenta );          string nombre = rs.getstring("nombre");            out.println("el nombre es:" + nombre );          string apellido_pat = rs.getstring("apellido_pat");            out.println("el apellido paterno es:" + apellido_pat );          string apellido_mat = rs.getstring("apellido_mat");            out.println("el apellido materno es:" + apellido_mat );          string direccion = rs.getstring("direccion");            out.println("la direccion es:" + direccion );          string telefono = rs.getstring("telefono");            out.println("el telefono es:" + telefono );          string edad = rs.getstring("edad");            out.println("la edad es:" + edad );  }     }         stmt.close();         conexion.close();        }     catch (classnotfoundexception e1) {             //error si no puedo leer el driver de mysql     out.println("error:no encuentro el driver de la bd: "+             e1.getmessage()); } catch (sqlexception e2) {             //error sql: login/passwd mal     out.println("error:fallo en sql: "+e2.getmessage()); } {             //finalmente desconecto de la bd     try {         if (conexion!=null)             conexion.close();     } catch (sqlexception e3) {         out.println("error:fallo al desconectar de la bd: "+             e3.getmessage());     }         } }  // <editor-fold defaultstate="collapsed" desc="httpservlet methods. click on + sign on left edit code."> /**  * handles http <code>get</code> method.  *  * @param request servlet request  * @param response servlet response  * @throws servletexception if servlet-specific error occurs  * @throws ioexception if i/o error occurs  */ @override protected void doget(httpservletrequest request, httpservletresponse response)         throws servletexception, ioexception {     processrequest(request, response); }  /**  * handles http <code>post</code> method.  *  * @param request servlet request  * @param response servlet response  * @throws servletexception if servlet-specific error occurs  * @throws ioexception if i/o error occurs  */ @override protected void dopost(httpservletrequest request, httpservletresponse response)         throws servletexception, ioexception {     processrequest(request, response); }  /**  * returns short description of servlet.  *  * @return string containing servlet description  */ @override public string getservletinfo() {     return "short description"; }// </editor-fold>  } 

i did servlet register data , works fine, pretty web works this, tried other projects , don't work, perhaps resultset? saw on 1 of stack traces resultset returning error. please help?


Comments