db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernt M. Johnsen" <Bernt.John...@Sun.COM>
Subject Re: check if DB exists already?
Date Thu, 09 Aug 2007 22:02:19 GMT
>>>>>>>>>>>> Teja wrote (2007-08-09 14:09:27):
> 
> If the database doesn't exist, I need to initalize it, create some tables and
> stuff... What should I do instead?

try {
   c = DriverManager.getConnection('...url...');
} catch (SQLException.....) {
   c = DriverManager.getConnection('...url...;create=true');
   .... initialize it, create tables and stuff
}

Just fill in the details. This should be fairly straight forward.


> 
> 
> Daniel John Debrunner-2 wrote:
> > 
> > Teja wrote:
> >> How do I check if the database exists already? I know create=true in the
> >> connection url creates if db doesn't exist and throws a SQLWarning if
> >> exists
> >> already, but is there a way to know for sure that a database exists
> >> already
> >> before connecting?
> > 
> > Why not just attempt a connection? What do you gain by knowing if the 
> > database exists or not?
> > 
> > Dan.
> > 
> > 
> 
> -- 
> View this message in context: http://www.nabble.com/check-if-DB-exists-already--tf4245044.html#a12080833
> Sent from the Apache Derby Users mailing list archive at Nabble.com.
> 

Mime
View raw message