This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes IllegalArgumentException when closing PreparedStatement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "IllegalArgumentException when closing PreparedStatement" Watch "IllegalArgumentException when closing PreparedStatement" New topic
Author

IllegalArgumentException when closing PreparedStatement

Joe Kidd
Greenhorn

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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30068
    
149

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


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, 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
Greenhorn

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 (http://bugs.mysql.com/bug.php?id=37645) was submitted back in 2008 (I just installed Netbeans 6.5.1 with Glassfish 2.1). There's another: http://bugs.mysql.com/bug.php?id=38699 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
Greenhorn

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:

http://www.netbeans.org/kb/60/web/mysql-webapp.html#settingUpConnPool

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

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: http://aspose.com/file-tools
 
subject: IllegalArgumentException when closing PreparedStatement
 
Similar Threads
Urgent....
EnumeratorException
Invalid user error message
java .lang .Number Format Error
Urrgent Pls Advice as soon as possible