Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

IllegalArgumentException when closing PreparedStatement

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
author & internet detective
Posts: 40035
809
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Driver bug? I don't know what else could cause that - it's very odd.
 
Ranch Hand
Posts: 2458
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Google the stacktrace. You'll land at a MySQL bug page.
 
Joe Kidd
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
You don't like waffles? Well, do you like this tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic