• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between execute() and executeQuery()

 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, I'd like to say many thanks to my fellow ranchers! You've all been so nice to me and have been so generous in helping the likes of me. So what's the difference between the execute() and executeQuery() methods? I tried using executeQuery() to create a database and I get an SQLException error (No result set was produced). Here's my code... Could you also help me pinpoint the problem? Thanks!

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
executeQuery(), as its name might suggest, is only used for executing queries. That is, SQL SELECT statements.

What sort of result set would expect from a create table statement?
[ October 16, 2005: Message edited by: Bear Bibeault ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34229
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that there is an executeUpdate() method to call for creates. It doesn't return a resultset because it doesn't apply for any update call.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic