This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

insert and preparedStatement

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Clapham
Sheriff
Posts: 21955
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
executeUpdate() is the one ;)
thanks, Paul
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!