2

I deploy my web app to the WildFly 8.02 Final server. I use default out of the box DataSource that comes with the server with jndi name space:

java:jboss/datasources/ExampleDS

and I use default url:

jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE

to access H2 from IntelliJ IDEA database client tool or other client applications (I use url connection, because tcp connection via default port doesn't work).

The app is basically an empty WAR with just entity beans and persistence.xml file. I intend to test purely what tables will be created in the underlying data source in accordance to my annotations.

Here is the thing: when I set in persistence.xml:

<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>

war is succesfully deployed, but when I connect via any client tool to the H2 data source I can see only pre-defined tables after:

SELECT * FROM INFORMATION_SCHEMA.TABLES

I can create tables via client tools and I am able to track their existence by the previous SQL query. So it seems that tables just hadn't been created by the JPA framework.

But when I change persistence.xml to the different schema creation mode:

<property name="javax.persistence.schema-generation.database.action" value="create"/>

Deployment will fail with jdbc exception telling that JPA tries to create already existing tables, but at the same time client tools still do not show any user created tables.

Thx.

1 Answer 1

2

Take a look at http://www.h2database.com/html/features.html#in_memory_databases :

To access an in-memory database from another process or from another computer, 
you need to start a TCP server in the same process as the in-memory database 
was created. The other processes then need to access the database over TCP/IP 
or TLS, using a database URL such as: jdbc:h2:tcp://localhost/mem:db1.

Look here for an example:

H2 database in memory mode cannot be accessed by Console

1
  • Great, thx a lot. Now at least I understand what is going on, hope I'll be able to configure wildfly's default DB to run as a TCP server.
    – Ivan
    Apr 22, 2015 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.