• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Difference between execute() and executeQuery()

 
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic