I'm new in developing apps in JBoss so I followed their tutorials specially in making the Ticket Monster. For now, I've created an Event JPA Entity and in the run, it shows that I can save an event. But when I restart my computer, it seems the event I've saved is lost, so research about it and found some info about in-memory database. My problem is how do I tell/configure my project not to use in-memory database but to use the typical database so every time I restarted my computer the data was in the database. I would like to use PostgreSQL for my database. My current datasource profile that is set to JPA is TestDB
but the datasource of my persistence.xml is
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="primary">
<!-- If you are running in a production environment, add a managed
data source, this example data source is just for development and testing! -->
<!-- The datasource is deployed as WEB-INF/ticket-monster-ds.xml, you
can find it in the source at src/main/webapp/WEB-INF/ticket-monster-ds.xml -->
<jta-data-source>java:jboss/datasources/ticket-monsterDS</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
</persistence>
it said that <jta-data-source>java:jboss/datasources/ticket-monsterDS</jta-data-source>
not the TestDB
. Also, I would like not use the create-drop
but instead a value that could tell if there is something in the database do not drop it but use it and or create if no existing.
UPDATE
Heres my ticket-monster-ds.xml
<datasources xmlns="http://www.jboss.org/ironjacamar/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
<!-- The datasource is bound into JNDI at this location. We reference
this in META-INF/persistence.xml -->
<datasource jndi-name="java:jboss/datasources/ticket-monsterDS"
pool-name="ticket-monster" enabled="true"
use-java-context="true">
<connection-url>jdbc:h2:mem:ticket-monster;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
</datasources>