db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Magnus Prime <magnuspr...@hotmail.com>
Subject Reading DDL SQL from JAR
Date Tue, 11 Mar 2008 17:47:48 GMT
Hi All,
I know there is probably a really easy way/answer to this, but I am struggling a bit.
I am trying to create a simple GUI app with Derby as my Embedded DB.
I have my SQL script in a .sql file, which is inside my JAR.  It contains all the create table
statements I need to create a new database in my app.  (Application allows multiple databases,
so thats why I am trying to do this.)  I am not having trouble reading the sql file, as the
getResourceAsStream method works fine.  
After I have read in my sql file into a String type, I try to do an execute on the dbconnection:
Statement stmt = dbconn.createStatement();
I have also tried executeUpdate and executeQuery.
Each time it complains either that it encountered a ; at the end of my create table statement,
or if I take that out, that it encounters another CREATE keyword.  Both situations cause SQLSyntaxExceptions
to be thrown.
So, finally the question...
Is there a way that I can run all my create table statements through one statement execute
call?  My SQL file is fine if I run it through ij, but through JDBC seems to not work.
Shed those extra pounds with MSN and The Biggest Loser!
View raw message