views:

389

answers:

3

Hi all.

I've managed to do some ant-script to populate my databases.. (simple script that runs some .sql files, like 'create', 'populate', 'drop', etc.)

Is there any way in hell that an ant-script can create the database itself from scratch? This is for JavaDB-Derby (from the glassfish bundle). Since it's a project for university, we find that we recreate the database on different machines all the time, and I would like to avoid this. Also it'd be great to know.

Normally I would create a database through Netbeans, and it would ask for a name, location, username, and then it would create the link derby:jdbc://localhost:1527//DBUsername/

I understand this is probably a bit too db-related, but since ant seems like a good tool maybe it could help.. or if not, maybe some other way (maybe another .sql file?)

Thanks for any replies.

+1  A: 

I've created databases via Ant. I don't recall having a problem executing DDL with the SQL task. You might want to check out DBUnit.

Nate
+1  A: 

Have you seen this link: Ant Script to create MySQL tables. Shouldn't be too hard to adapt it for Derby.

OMG Ponies
+1  A: 

Apache Derby's JDBC driver lets you create a database using ;create=true flag in the connection string:

jdbc:derby:MyDatabase;create=true

You can do this from Ant by running ij tool as command-line (or as java app). Here's a link to documentation

ChssPly76