File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes No ResultSet was produced Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "No ResultSet was produced" Watch "No ResultSet was produced" New topic
Author

No ResultSet was produced

Rob Sammons
Greenhorn

Joined: Mar 16, 2005
Posts: 5
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

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Rob Sammons
Greenhorn

Joined: Mar 16, 2005
Posts: 5
I didn't expect any ReultSet but I get the same error message even without the ResulSet rs part
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

...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

Joined: Mar 16, 2005
Posts: 5
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

Joined: Apr 14, 2004
Posts: 10336

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

Joined: Mar 16, 2005
Posts: 5
I've managed to fix it now and everythings working fine. Thanks for your your help.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You are welcome. Just out of interest what was wrong?
Rob Sammons
Greenhorn

Joined: Mar 16, 2005
Posts: 5
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: No ResultSet was produced