db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@apache.org>
Subject Re: Question about creating additional dbs in the junit
Date Tue, 20 Mar 2007 04:25:26 GMT
Manjula Kutty wrote:
> Hi
> I'm trying to convert lang/ShutdownDatabase.java test to junit. But that 
> particular test created different databases and verifies the shutdown in 
> different scenarios. I tried creating new database like this (please see 
> the code snippet)
> When I checked the the dbname created is singleUse/oneuse0. how can I 
> create the db with the name I want, Or am I doing something seriously 
> wrong???

No, the tests request a database using a logical name and the decorator 
maps it into a physical name. This is to allow (in the future) multiple 
concurrent test runs by not relying on a hard coded database name. It 
also provides a single clean location for these "single use databases".

The openConnection() call you made is only expecting a logical database 
name, not a name with a set of attributes.

You can either obtain a data source to perform the shutdown using
and set the shutdown attributes on that data source.

If you must use the DriverManager api (which means the test will not be 
able to run on J2ME) then most likely you will need to write new utility 

I think though that keeping a clean separation between database names, 
JDBC attributes, data source properties and JDBC URL is good practice.
Using "dbname;create=true" as a database name is likely to cause 
problems, because it's not a database name, it's part of a JDBC URL. 
Just because it happens to work in some situations doesn't mean it's a 
good idea, I'm not sure if that will work, for example, in J2ME.


View raw message