Tom Enders

Greenhorn
+ Follow
since Mar 27, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tom Enders

It's working now. The problem was with my inserts. They were not executing because I had some bad boolean logic surrounding them. So, the problem wasn't actually with this piece of code.
Why is my record set closed when I try to read from it the line after I execute the sql statement?

Theo Arril wrote:Hello,
I tried your solution but I got many errors.

First of all you must know that there's no direct way to execute an SQL script file directly through JDBC
You can't load a SQL file into one statement and excute it.

You will have to write your own (very little) parser to split the script in individual statements and execute them one by one.
Splitting in Statements is the biggest challenge here ; so here is my solution :



That's my solution, so try and tell me about it !!



Your parser does not work on a file that contains transactions. I found this when I tried to run it on a file to create a database which contained triggers. So, I rewrote the parser. Here is the code, the comments should be enough to explain it. So use this just replace the split line in Theo's solution with the following code.