my dog learned polymorphism
The moose likes JDBC and Relational Databases and the fly likes insert and preparedStatement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Customer Requirements for Developers this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "insert and preparedStatement" Watch "insert and preparedStatement" New topic
Author

insert and preparedStatement

miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
i'm using this code:

but i get an error:
java.sql.SQLException: Can not issue data manipulation statements with executeQuery().

is it not possible to use my insert sql with '?' and preparedstatements?

TiA


java amateur
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19693
    
  10

Of course it is possible. But (as the error message says) you cannot use the executeQuery() method to do that. You should use the executeUpdate() method instead.
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
executeUpdate() is the one ;)
thanks, Paul
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: insert and preparedStatement
 
It's not a secret anymore!