
上QQ阅读APP看书,第一时间看更新
DS file
This file can be put inside the application or deployed with the default instruments provided by WildFly. It is recognized by the extension that it must end with -ds.xml. Here's a sample of jpa-ds.xml:
<datasources xmlns="http://www.jboss.org/ironjacamar/schema">
<xa-datasource
jndi-name="java:/jboss/datasources/forums_mdefault" pool-name="forums_mdefault">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource
</xa-datasource-class>
<xa-datasource-property name="URL">jdbc:h2:mem:test
</xa-datasource-property>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
</security>
</xa-datasource>
</datasources>
Each DataSource provides a JNDI name to be called simply. The persistence unit calls the DataSource through it. In this sample we can see the JDBC driver, used to distinguish the database, the connection URL, and the username where to access it. A real DataSource will get a password field too. For simplicity we use H2, an in-memory database used for tests. By default it doesn't need the password.