Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No ResultSet was produced

 
Rob Sammons
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I'm trying to insert values into an access database but whenever I execute my query I get the Error message No ResultSet was produced. I can't work out why this is can someone please point me in the right direction. ere is my code:

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What sort of ResultSet would you expect from an INSERT statement? You might like to look at the various executeUpdate() methods of java.sql.Statement.
 
Rob Sammons
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't expect any ReultSet but I get the same error message even without the ResulSet rs part
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and if you didn't expect any ResultSet, why are you choosing to use a method which returns one? Especially as there are other methods which don't return a ResultSet available in the java.sql.Statement class? Have a read of the JavaDocs for that class and I'm sure you'll spot the more appropriate way of doing this.
 
Rob Sammons
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks I used executeUpdate instead and that worked fine but I now have a new problem that I get the error "Too few parameters. Expected 1" even though I have made sure I have the right amount of parameters when I run my constructor. It works fine if I hardcode in the sql Query.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stick in a log statement which outputs the value of sqlQuery and cut and paste that into whichever database client you like to use to check it is a you expect it to be.
 
Rob Sammons
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've managed to fix it now and everythings working fine. Thanks for your your help.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome. Just out of interest what was wrong?
 
Rob Sammons
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The sql query to insert a new row was not in the propper format. I had not put any inverted commas ' around the string variables to be inserted.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic