I have found a solution to my problem: I create the database in persistence.xml (notice the ";create=true" in the value of "toplink.jdbc.url") instead of in build.xml:
<persistence-unit name="alexandria" transaction-type="RESOURCE_LOCAL"> <provider>oracle.toplink.essentials.PersistenceProvider</provider> <class>org.alexandria.entity.Book</class> <properties> <property name="toplink.jdbc.url" value="jdbc:derby:/home/josepma/documents/assigna/models/apunts/5.ContinuousIntegration/examples/jpa-derby-test/myDB;create=true"/> <property name="toplink.ddl-generation" value="create-tables"/> <property name="toplink.jdbc.user" value="josepma"/> <property name="toplink.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/> <property name="toplink.jdbc.password" value="josepma"/> </properties> </persistence-unit> </persistence> If done this way, it is not necessary to include a "create-db" target in build.xml. However, I do not fully understand the behaviour of the derby embedded driver. Therefore, if someone can provide some light on this subject, I would be grateful. Thanks again., Josepma -- View this message in context: http://apache-database.10148.n7.nabble.com/ant-jpa-junit-derby-Cannot-connect-to-the-database-already-booted-tp128487p128506.html Sent from the Apache Derby Users mailing list archive at Nabble.com.