You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Magnus Prime <ma...@hotmail.com> on 2008/01/03 15:43:24 UTC
Check for DB Existence on Start
Hi.
I am fairly new to derby, but I am enjoying it so far. What I want to know, is there a way to connect to Derby, and check that the DB you want to use exists, and if not, then go create it.
I am using the embedded driver (in a Java program), and I know I can add the ;create flag to the URL, but does that have any adverse effects if the DB has already been created?
The end result of what i am trying to accomplish, is that the first time the program is run, create the required DB and its tables/sample data, and from then on, dont create it if it already exists.
Thanks
_________________________________________________________________
The best games are on Xbox 360. Click here for a special offer on an Xbox 360 Console.
http://www.xbox.com/en-US/hardware/wheretobuy/
Re: Check for DB Existence on Start
Posted by Donald McLean <dm...@gmail.com>.
Dear Magnus,
On the Derby Wiki, I have posted the source for a DatabaseManager class that
does this (among other things):
http://wiki.apache.org/db-derby/DatabaseManager
The current version of DatabaseManager does much more but unfortunately I am
not free to post that source code.
Donald
On Jan 3, 2008 9:43 AM, Magnus Prime <ma...@hotmail.com> wrote:
>
> Hi.
>
> I am fairly new to derby, but I am enjoying it so far. What I want to
> know, is there a way to connect to Derby, and check that the DB you want to
> use exists, and if not, then go create it.
>
> I am using the embedded driver (in a Java program), and I know I can add
> the ;create flag to the URL, but does that have any adverse effects if the
> DB has already been created?
>
> The end result of what i am trying to accomplish, is that the first time
> the program is run, create the required DB and its tables/sample data, and
> from then on, dont create it if it already exists.
>
>
Re: Check for DB Existence on Start
Posted by Thomas Nielsen <Th...@Sun.COM>.
Hi Magnus,
Check out this recent thread from the userlist. It should contain
exactly what you need:
http://www.nabble.com/check-if-DB-exists-already--to12080193.html#a12080193
Cheers,
Thomas
Magnus Prime wrote:
>
> Hi.
>
> I am fairly new to derby, but I am enjoying it so far. What I want to
> know, is there a way to connect to Derby, and check that the DB you want
> to use exists, and if not, then go create it.
>
> I am using the embedded driver (in a Java program), and I know I can add
> the ;create flag to the URL, but does that have any adverse effects if
> the DB has already been created?
>
> The end result of what i am trying to accomplish, is that the first time
> the program is run, create the required DB and its tables/sample data,
> and from then on, dont create it if it already exists.
>
> Thanks
>
>
> ------------------------------------------------------------------------
> The best games are on Xbox 360. Click here for a special offer on an
> Xbox 360 Console. Get it now!
> <http://www.xbox.com/en-US/hardware/wheretobuy/>
--
Thomas Nielsen