Destroying JBoss AS 7.1.1 Database after Restart

I am using JBoss AS 7.1.1 and I have a problem with my database - it gets erased every time I restart the server. Below you can see the contents of my save file:

<?xml version="1.0" encoding="UTF-8"?> 
<persistence version="1.0" 
            xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
            xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> 
    <persistence-unit name="wyklad2"> 
        <provider>org.hibernate.ejb.HibernatePersistence</provider> 
        <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source> 
        <properties> 
            <property name="hibernate.hbm2ddl.auto" value="update" /> 
            <property name="hibernate.show_sql" value="false" /> 
        </properties> 
    </persistence-unit> 
 </persistence>

      

DataSource config:

    <subsystem xmlns="urn:jboss:domain:datasources:1.0"> 
            <datasources> 
                <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true"> 
                    <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url> 
                    <driver>h2</driver> 
                    <security> 
                        <user-name>sa</user-name> 
                        <password>sa</password> 
                    </security> 
                </datasource> 
                <drivers> 
                    <driver name="h2" module="com.h2database.h2"> 
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class> 
                    </driver> 
                </drivers> 
            </datasources> 
        </subsystem>

      

I would be very grateful for any hint that can help me fix this problem.

+3


source to share


1 answer


The data source you are using is an in-memory h2 database. When your server goes down, this DB ceases to exist.

Switch to a real database instead.



For h2, the syntax is jdbc:h2:~/mydb;DB_CLOSE_DELAY=-1

for the database located at ~ / mydb. Use any path (you must have write access).

+10


source







All Articles