Database access with Ant! tools 15649 6401

Database access with Ant!

You can access a database with Ant. This can be useful when you want to create a database and fill it with some default data at the start/deployment of a project, but also when you want to reset the contents of your database just before invoking your tests!

Example of an Ant target to create a table:




CREATE TABLE br_vote
(
voteid INTEGER NOT NULL,
reviewid INTEGER NOT NULL,
votevalue INTEGER DEFAULT 5 NOT NULL
);


The accompanying build.properties for MySQL access in this case reads:

mysql.password = MyDatabaseUserPassword
mysql.user = MyDatabaseUserName
mysql.driver = com.mysql.jdbc.Driver
mysql.url = jdbc:mysql://localhost/myDatabase
mysql.classpath = /classpath/to/mysql-jdbc.jar

Mutatis mutandum for the build.properties, I was also able to successfully access an Oracle DB (LUDO).

Of course, you can also populate a DB this way, by just formulating a different target and putting the appropriate SQL statements in.

8 Comments

  1. budowa domów June 21, 2007
  2. Pingback: Bad Credit Credit Cards April 28, 2007
  3. Pingback: Puma Shoes April 26, 2007
  4. Pingback: Ties April 26, 2007
  5. Pingback: Bad Credit Credit Cards April 25, 2007
  6. Pingback: Magazine April 24, 2007
  7. Pingback: Bowling Shoes April 24, 2007
  8. Pingback: Wireless Camera Shop April 23, 2007
  9. Lucas December 3, 2004
  10. Coca IQ Bogdan December 1, 2004
  11. Jay August 30, 2004
  12. Lucas August 28, 2004
  13. Jay August 27, 2004
  14. Lucas Jellema July 6, 2004
  15. Zeger Hendrikse June 30, 2004