Hello,
I am using ant+jpa+junit+derby(embedded).
I am trying to write a build.xml file which:
(1) Creates a derby database with the embedded driver
(2) Runs the tests of a test class.
However, when the junit ant task runs the tests in the test class, I get:
java.sql.SQLException: Another instance of Derby may have already booted the
database /pathToMyDB.
These are the relevant parts of my build.xml script:
<target name="create-db">
<delete dir="${db.dir}"/>
<sql classpathref="classpath" userid="josepma" password="josepma"
url="jdbc:derby:${db.dir};create=true"
driver="org.apache.derby.jdbc.EmbeddedDriver">
;
</sql>
</target>
<target name="test" depends="create-db, compile">
<junit printsummary="yes" haltonerror="yes" haltonfailure="yes"
fork="no">
<formatter type = "xml" />
<classpath>
<path refid="classpath"/>
</classpath>
<batchtest todir="${build.report.dir}" >
<fileset dir="${src.test.dir}">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
ANd this is what I do in the test class:
@Test
public void testAddBook() {
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("alexandria");
EntityManager em = emf.createEntityManager();
System.out.println("addBook");
}
I have been stuck in this for a couple of days. I would appreciate some
help!!!
Thank you.
Josepma
--
View this message in context:
http://apache-database.10148.n7.nabble.com/ant-jpa-junit-derby-Cannot-connect-to-the-database-already-booted-tp128487.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.