I’m trying to run my web application using Wildfly Swarm and .war packaging.
How should i add my jdbc driver and data source definition?
Answer
In the simple case where you can simply use the default data source in your persistence unit, you can just specify the connection details using the following Java system properties:
swarm.ds.name - Name of the datasource (e.g. ExampleDS)
swarm.ds.username - Username to access the database
swarm.ds.password - Password to access the database
swarm.ds.connection.url - URL connection to use
Setting these values configures the JTA data source, so you can have a very basic persistence.xml:
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"> <persistence-unit name="example"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <class>entity.user</class> <properties> <property name="hibernate.hbm2ddl.auto" value="create" /> <property name="hibernate.show_sql" value="true"/> </properties> </persistence-unit> </persistence>
The datasource name doesn’t seem to matter.
For (slightly) more information, see https://wildfly-swarm.gitbooks.io/wildfly-swarm-users-guide/content/configuration_properties.html
Attribution
Source : Link , Question Author : Julio Faerman , Answer Author : Doctor Eval