lb.
lb.

Reputation: 5786

Creating database (not populating it) through Ant build file

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.

Upvotes: 1

Views: 1680

Answers (2)

ChssPly76
ChssPly76

Reputation: 100746

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

Upvotes: 1

Nate
Nate

Reputation: 2456

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.

Upvotes: 1

Related Questions