db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Manjula Kutty" <manjula.ku...@gmail.com>
Subject Re: Question about creating additional dbs in the junit
Date Tue, 20 Mar 2007 19:27:20 GMT
Thanks for the detailed reply Dan. Even I think the same that we should not
create databases with hardcoded names. I will follow the same rule and will
try to convert the test


On 3/19/07, Daniel John Debrunner <djd@apache.org> wrote:
> 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)
> [snip]
> >
> > 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
> JDBCDataSource.getDataSourceLogical()
> 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
> methods.
> 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.
> Dan.


View raw message