Thread: Query Executor Problem

Query Executor Problem

From
"Email User"
Date:
Hi,
Our web based application which is using postgresql version 7.1.3  is
showing an error as follows.

 java.lang.NullPointerException
        at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:61)
        at org.postgresql.Connection.ExecSQL(Connection.java:398)
        at org.postgresql.jdbc2.Statement.execute(Statement.java:130
        at org.postgresql.jdbc2.Statement.executeQuery(Statement.java:54)
        at
com.ebusinessoft.gen.db.DatabaseUtilities.getQueryResults(DatabaseUtilities.java:71)
        at com.ebusinessoft.ifos.rsmt.gentrip.doGet(gentrip.java:124)
        at com.ebusinessoft.ifos.rsmt.gentrip.doPost(gentrip.java:448)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        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.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:166)
        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)


This type of message occurs at random and we could not assess the reason for
this. We greatly  appreciate your help on this.

Thanks
Support
support@ebusinessoft.com


Re: Query Executor Problem

From
"Daniel Germain"
Date:
In our case we had to make sure
to discard/close/clean the connection ourself
EVERYWHERE.
We realized that in some circonstances our application server
did not release and close properly the connection from our pool.

Usually it called connection.clearWarnings(),
connection.setAutoCommit(true);
and closes the connection whenever there was an exception.

Strange things happen when the GarbageCollector/Finalizer runs
and tries to call the method org.postgresql.Connection.finalize()
which calls org.postgresql.Connection.close which execute pg_stream=null;
And it is this variable pg_stream which is null in the QueryExecutor at
line 61. The finalizer seems to disrupt internal stuff that it should not
have (database socket?), anyway you should not rely on the finalize method.

From what I remember is that we make sure WE close the connection and
not the gargage collector.
The Connection.close instruction should be the last instruction you execute
on a connection.

Good luck.

Daniel

> -----Original Message-----
> From: Email User [mailto:support@ebusinessoft.com]
> Sent: November 6, 2002 1:35 AM
> To: daniel.germain@gipsynet.com
> Cc: pgsql-jdbc@postgresql.org
> Subject: Query Executor Problem
>
>
> Hi,
> Our web based application which is using postgresql version 7.1.3  is
> showing an error as follows.
>
>  java.lang.NullPointerException
>         at
> org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:61)
>         at org.postgresql.Connection.ExecSQL(Connection.java:398)
>         at org.postgresql.jdbc2.Statement.execute(Statement.java:130
>         at org.postgresql.jdbc2.Statement.executeQuery(Statement.java:54)
>         at
> com.ebusinessoft.gen.db.DatabaseUtilities.getQueryResults(Database
> Utilities.java:71)
>         at com.ebusinessoft.ifos.rsmt.gentrip.doGet(gentrip.java:124)
>         at com.ebusinessoft.ifos.rsmt.gentrip.doPost(gentrip.java:448)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
>         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(ContextManag
> er.java:797)
>         at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
>         at
> org.apache.tomcat.service.connector.Ajp12ConnectionHandler.process
> Connection(Ajp12ConnectionHandler.java:166)
>         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)
>
>
> This type of message occurs at random and we could not assess the
> reason for
> this. We greatly  appreciate your help on this.
>
> Thanks
> Support
> support@ebusinessoft.com
>


Re: Query Executor Problem

From
"David Hooker"
Date:
I had this error as well, and tracked it down to my trying to use a
Connnection object that had been closed.

-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Email User
Sent: Wednesday, November 06, 2002 12:35 AM
To: daniel.germain@gipsynet.com
Cc: pgsql-jdbc@postgresql.org
Subject: [JDBC] Query Executor Problem


Hi,
Our web based application which is using postgresql version 7.1.3  is
showing an error as follows.

 java.lang.NullPointerException
        at
org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:61)
        at org.postgresql.Connection.ExecSQL(Connection.java:398)
        at org.postgresql.jdbc2.Statement.execute(Statement.java:130
        at
org.postgresql.jdbc2.Statement.executeQuery(Statement.java:54)
        at
com.ebusinessoft.gen.db.DatabaseUtilities.getQueryResults(DatabaseUtilit
ies.java:71)
        at com.ebusinessoft.ifos.rsmt.gentrip.doGet(gentrip.java:124)
        at com.ebusinessoft.ifos.rsmt.gentrip.doPost(gentrip.java:448)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        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.jav
a:797)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
        at
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnec
tion(Ajp12ConnectionHandler.java:166)
        at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416
)
        at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:49
8)
        at java.lang.Thread.run(Thread.java:484)


This type of message occurs at random and we could not assess the reason
for
this. We greatly  appreciate your help on this.

Thanks
Support
support@ebusinessoft.com


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster


Re: Query Executor Problem

From
Date:
Me too. I had the some problem. And couldn't figure out why when I was using tomcat. The point is that the docs at
jakarta.apache.orgdo not really explain the use of the parameters for me. If you use some database as a datasource, the
connectionswill go back into the pool, for a while and get recycled, so you should never call connection.close() when
youretrieve a database using a DataSource object from a jndi tree. Just don't forget to set the <maxIdle> parameter to
aacceptable high value (higher that the <maxActive> parameter which is the number of connections that are actually
openedby tomcat to process any request). This way the connections will get pooled and recycled correctly.
 


>I had this error as well, and tracked it down to my trying to use a
>Connnection object that had been closed.
>
>-----Original Message-----
>From: pgsql-jdbc-owner@postgresql.org
>[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Email User
>Sent: Wednesday, November 06, 2002 12:35 AM
>To: daniel.germain@gipsynet.com
>Cc: pgsql-jdbc@postgresql.org
>Subject: [JDBC] Query Executor Problem
>Hi,
>Our web based application which is using postgresql version 7.1.3 
>java.lang.NullPointerException
>        at
>org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:61)