I'm new to Derby and I'm trying to figure out how to load a database
from a file if it doesn't already exist when loading the driver for the
first time. I know I'm getting an SQLState of XJ004 and an ErrorCode of
40000. This is code for when the application first starts up -- if the
db doesn't exist -- let's create it unbeknownst to the user. What I
would like to do is catch the exception. If the DB is not there, I want
to create it, load it from the "bogus.SQL" text file and then try again:
try {
_conn = DriverManager.getConnection("jdbc:derby:bogusdb");
}
catch (SQLException e){
<if SQLState = XJ004; create db with
"jdbc:derby:bogusdb;create=true">
<load db schema from file "bogus.SQL">
<try "DriverManager.getConnection("jdbc:derby:bogusdb")" again>
...
}
}
Can anybody point me to the correct location in the documentation? I'm
thinking that I'll need to load the file using IJ, but I'm not sure how
to load the schema from a text file....
P.S. Great presentation Dan & Dave. I've been a list follower for a few
months. I hadn't thought about to the memory stick idea:
http://developers.sun.com/learning/javaoneonline/sessions/2006/TS-3154/index.html