Skip to Main Content

Java Database Connectivity (JDBC)

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!

executing sql script from file, with multiple queries

843854Jun 2 2005 — edited May 14 2007
Hello,

I am trying to load an SQL script from a file, parse the script into separate SQL statements, and execute each of them. The final statement will always be a query, and thus will return a result.

Three problems arise:

1. I don't know what TYPE of statement each one is (i.e. whether it is an UPDATE or a QUERY), which seems to be required in order to execute it in java (via executeQuery and executeUpdate).

2. I am not sure of the best way to execute a series of statements (the Statement object has some "batch" functionality, but I'm not sure if there is a better way, or even of the proper way to use this).

3. I need to be able to make sure the final statement is a QUERY, and thus will return a ResultSet. Otherwise I need to be able to throw an exception.


This has been causing me a lot of trouble. Any help would be much appreciated.

Thanks,
Kevin
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 11 2007
Added on Jun 2 2005
3 comments
487 views