Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Can not issue data manipulation statements with executeQuery()

843836Nov 3 2003 — edited Nov 3 2003
Hi all,

1/ This works :

PreparedStatement stmt = con.prepareStatement("insert into matable(nom,pass) values (?,?)");
stmt.setString(1,nom);
stmt.setString(2,pass);
stmt.executeUpdate();

2/ This causes exception : Can not issue data manipulation statements with executeQuery()

PreparedStatement stmt = con.prepareStatement("insert into matable(nom,pass) values (?,?)");
stmt.setString(1,nom);
stmt.setString(2,pass);
stmt.executeQuery();

3/ But this works...

PreparedStatement stmt = con.prepareStatement("insert into matable(nom,pass) values (?,?)");
stmt.setString(1,nom);
stmt.setString(2,pass);
ResultSet rs = stmt.executeQuery();

1/ and 2/ are on tomcat 5 with org.gjt.mm.mysql.Driver 3.O

3/ is under jrun 3.1 with org.gjt.mm.mysql.Driver 2.0.4

weird ?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 1 2003
Added on Nov 3 2003
1 comment
629 views