users@glassfish.java.net

Connection pool connection returns null from prepareStatement()?

From: <glassfish_at_javadesktop.org>
Date: Wed, 07 Oct 2009 06:43:45 PDT

I am seeing something mysterious that seems to have as its root cause some part of Glassfish's connection pool machinery.

I'm using Glassfish 2.1b60e and MySQL Connector/J 5.1.

Today, for no reason, and after no code changes, a particular invocation of connection.prepareStatement("statement code here", Statement.RETURN_GENERATED_KEYS) began returning null, leaving behind no trace in the error log that anything had gone wrong. An assertion I had placed after this statement (assert s != null) began failing.

Interestingly, to get to this point, the program has had to get and successfully use other connections.

Also interestingly, it fails reliably at this particular point in the program.

When I asked Connector/J to profile its SQL, I can tell that the actual connection seems to be some kind of connection wrapper vended by Glassfish, and in some com.sun package, which is why I brought the problem here instead of to the MySQL guys.

With no log information, no stack traces and nothing else to go on, I am at a loss. Any ideas? Is there a known problem with Glassfish's connection pool?

Thanks,
Laird
[Message sent by forum member 'ljnelson' (ljnelson_at_gmail.com)]

http://forums.java.net/jive/thread.jspa?messageID=367122