It's not a secret anymore!
The moose likes JDBC and Relational Databases and the fly likes IllegalArgumentException when closing PreparedStatement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "IllegalArgumentException when closing PreparedStatement" Watch "IllegalArgumentException when closing PreparedStatement" New topic

IllegalArgumentException when closing PreparedStatement

Joe Kidd

Joined: Apr 12, 2009
Posts: 6
The following method is from a User bean. The method is used to verify login information by comparing information entered by a user against a MySQL database.

Why would closing a PreparedStatement cause an exception to be thrown? The program runs fine if stmt.close(); is commented out... So, closing the ResultSet is fine, as is closing the Connection, but not the PreparedStatement

Here's the exception:
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33102

Driver bug? I don't know what else could cause that - it's very odd.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Google the stacktrace. You'll land at a MySQL bug page.
Joe Kidd

Joined: Apr 12, 2009
Posts: 6
Bauke Scholtz wrote:Google the stacktrace. You'll land at a MySQL bug page.

I have, I searched for a while before I posted. The reason I ended up posting the question is because the MySQL bug you mentioned ( was submitted back in 2008 (I just installed Netbeans 6.5.1 with Glassfish 2.1). There's another: that says there is a working fix. I just wanted to see if I was doing something wrong in my code, which I guess isn't the case.
Any idea how I could use the new version of MySQL Connector in Glassfish 2.1? Where should I put the .jar file and how do I make the server use it?
Joe Kidd

Joined: Apr 12, 2009
Posts: 6
Ok, I figured out how to "fix" this problem. The idea is to setup the connection pool and the resource through NetBeans (I'm using 6.5.1) as opposed to through the Glassfish (2.1) admin console. There's a very nice tutorial that explains how to do this on the NetBeans website:

I hope this helps anyone who ran into a similar problem.
TestConfig testConfig

Joined: Feb 16, 2012
Posts: 3
Hi All,

I know this is a old post,I was also getting the above exception while closing the PreparedStatement.
Inorder to fix that problem I updated latest Mysql jar in the Glassfish server.
As said by Jeanne Boyarsky.

Hope this helps
I agree. Here's the link:
subject: IllegalArgumentException when closing PreparedStatement
It's not a secret anymore!