• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

QueryRunner with null param

 
Chuck McKiel
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using QueryRunner and an MSAccess DB. I'm getting SQLExceptions when I call qr.update, but ONLY when I send it an Object[] of parameters with one or more null values. In other words, everything works just fine as long as none of the replacement parameters are null. In fact, if I simply change each null to a zero, the entire program completes successfully and the database gets filled in nicely (with zeros where the nulls should be). (And btw, using the empty string instead of null isn't an option).

I've tried changing everything around to just use a PreparedStatement instead of QueryRunner, but I had the same trouble... so I'd like to stick with QueryRunner once I solve this problem.

The error message I get is:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Invalid SQL data type

Any ideas? Any help at all would be much appreciated.
Thanks.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chuck,
Welcome to JavaRanch!

For the prepared statement, you need to call the setNull() method when passing a null. It takes the specific type to pass as null as a paramter. I'm not sure how it works when using the commons utility.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic