Thread: Problem with JDBC Driver / Statement.executeQuery()

Problem with JDBC Driver / Statement.executeQuery()

From
pgsql-bugs@postgresql.org
Date:
Kevin Rood (kevinrood@gdcemtral.com) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
Problem with JDBC Driver / Statement.executeQuery()

Long Description
I am using PostgreSQL and Tomcat on Red Hat Linux 7.0 to develop a database enabled webapp.

The combination seems to work fine except when I repeatedly request a page.  It seems that around 7-11 requests in a
rowwith a short time between requests will result in the exception and stack trace in example code. 

The exception gets thrown at the line 's.executeQuery( query );'.

Any help is appreciated.

Sample Code
private boolean validUser( String userID, String password, Connection c ) throws SQLException {
    String query = "SELECT gb_admin.user_id, password " +
                   "FROM gb_admin, gb_user " +
                   "WHERE gb_admin.user_id = gb_user.user_id AND " +
                   "      gb_admin.user_id = '" + userID + "' AND " +
                   "      gb_user.password = '" + password + "'";

    Statement s = c.createStatement();
    ResultSet rs = s.executeQuery( query );

    if ( rs.next() ) {
      rs.close();
      s.close();
      return true;
    }
    else {
      rs.close();
      s.close();
      return false;
}

---------------------------
Here's the stack trace:

Error: 500
Location: /kevin/servlet/AdminLogin
Internal Servlet Error:

java.lang.NullPointerException
    at org.postgresql.Connection.ExecSQL(Connection.java:312)
    at org.postgresql.jdbc2.Statement.execute(Statement.java:273)
    at org.postgresql.jdbc2.Statement.executeQuery(Statement.java:54)
    at AdminLogin.isValidAdminUser(AdminLogin.java:120)
    at AdminLogin.doGet(AdminLogin.java:77)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
    at org.apache.tomcat.core.Handler.service(Handler.java:286)
    at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
    at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
    at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
    at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
    at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
    at java.lang.Thread.run(Thread.java:484)


No file was uploaded with this report