NullPointerException « JDBC « Java Database Q&A





3. Prepared Statement null pointer exception help    coderanch.com

Sorry for the newb question but I'm really stumped and not too good when it comes to this jdbc stuff. All I'm trying to do is get a resultset from a "select *" query. I want to write the values to another table with an insert statement using the prepared statement. My output ends up looking like this: > java ManualCreditInsertion ...

5. NullPointerException in PreparedStatement...    coderanch.com

java.lang.NullPointerException at com.rajk.javacode.servlets.LoginModel.checkSession(LoginModel.java:20 8) at com.rajk.javacode.servlets.LoginServlet.doPost(LoginServlet.java:43) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV alve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j ava:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal ve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav a:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java :844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce ss(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44 7) at java.lang.Thread.run(Unknown Source) Check Session:0 admin null null Check Session1: admin 0 0 1216806108171 0 admin admin

6. NullPointerException on PreparedStatement    coderanch.com

public void populateComboBox(JComboBox cb) { DatabaseManager dbMgr = DatabaseManager.getInstance(); Connection dbConnection = dbMgr.getConnection(); PreparedStatement pStmt = null; ResultSet rs = null; MyComboBoxModel cm = (MyComboBoxModel) cb.getModel(); cm.removeAllElements(); try { pStmt = dbConnection.prepareStatement( // <--- Get NullPointerException HERE. "SELECT source_id, source_name FROM Source ORDER BY source_name"); rs = pStmt.executeQuery(); while (rs.next()) { cm.addElement( rs.getString("source_id"), rs.getString("source_name")); } if (cm.isEmpty()) { cm.addElement("-1", "None"); } ...