AFAIK The behavior you're looking for is not well defined by the JDBC API:

 http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Statement.html
 
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Statement.html#addBatch(java.lang.String)

Perhaps some JDBC drivers implement the behavior you expect, but
technically, you should call addBatch() to add each individual SQL
statement to the batch prior to calling executeBatch().

Perhaps if you post to the sqlitejdbc mailing list, the author may consider
making such an extension. But you can probably get away with just splitting
your DDL string on ";" and feeding them to addBatch in a loop and then
calling executeBatch.

--- "Steven E. Harris" <[EMAIL PROTECTED]> wrote:
> I'm using the "pure" SQLite JDBC driver¹ and trying to bootstrap my
> database schema by running a batch of DDL statements. I read in the
> entire DDL script from a file, collect it into a string, and feed that
> string into either java.sql.Statement.executeUpdate() or
> java.sql.Statement.executeBatch().
> 
> In either case, only the first DDL statement takes effect, and no
> errors are signaled. Stepping through the JDBC driver, it looks as
> though it sqlite3_prepare()s a statement with my SQL string, then
> calls sqlite3_step() on the statement, and the return value comes back
> as SQLITE_DONE, upon which it finalizes the statement and returns
> successfully.
> 
> I understand that we have this JDBC layer in the middle, but it's
> pretty thin, and I'm trying to figure out which party in this
> arrangement is responsible for only executing the first statement (up
> through the first semicolon) in the SQL string.
> 
> Does SQLite normally execute more than one statement provided in a SQL
> string? I'm fearing having to cut up this DDL file into ten parts:
> three CREATE TABLE statements, one CREATE INDEX statement, and six
> CREATE TRIGGER statements for foreign key enforcement.
> 
> Please advise.
> 
> 
> Footnotes: 
> ¹ http://www.zentus.com/sqlitejdbc/



 
____________________________________________________________________________________
Sucker-punch spam with award-winning protection. 
Try the free Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/features_spam.html

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to