简体   繁体   中英

howto: in-memory derby db with glassfish

I need run arquillian+junit tests on a remote Glassfish 4.1 server. The database tables for these test cases needs to be
(1) created in-memory ,
(2) with embedded JavaDB and
(3) dropped after the test execution.

Would the following glassfish-resources.xml work?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC
    "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN"
    "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
    <jdbc-resource pool-name="ArquillianEmbeddedDerbyPool"
                   jndi-name="java:app/jdbc/chapter2" />
    <jdbc-connection-pool name="ArquillianEmbeddedDerbyPool"
                          res-type="javax.sql.DataSource"
                          datasource-classname="org.apache.derby.jdbc.EmbeddedDataSource"
                          is-isolation-level-guaranteed="false">
        <property name="databaseName" value="memory:action-bazaar-db"/>
        <property name="createDatabase" value="create"/>
    </jdbc-connection-pool>
</resources>

I did try it but not sure if the database is created in-memory. I keep getting the below error every time I run the tests. How to get rid of this error?

PER01000: Got SQLException executing statement "CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(15), PRIMARY KEY (SEQ_NAME))": java.sql.SQLException: Table/View 'SEQUENCE' already exists in Schema 'APP'

If you are using Maven for your build, you can use the derby-maven-plugin , which I wrote and is available on GitHub and via Maven Central.

You can check here for my answer to a similar question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM