A persistence instance configuration is contained in a <persistence-instance>
element.
This element must have the following attributes:
Attribute | Description |
---|---|
name |
The name of the persistence instance. This name must be unique between all persistence instance configurations. |
datasource-class-name |
The fully-qualified name of the Java class from the database driver that implements the |
A <persistence-instance>
element may also include zero or more <parameter>
elements.
Each <parameter>
element identifies the name, Java type, and value of a configuration property of the datasource class using the following element attributes:
Attribute | Description |
---|---|
name |
The name of a JavaBean property defined by the datasource class. |
type |
The fully-qualified Java class name of the JavaBean property’s type. |
value |
The value that should be assigned to the configuration property.
|
Example
Below is an example of the default configuration that connects to a PostgreSQL database:
<persistence-instance datasource-class-name="org.postgresql.ds.PGSimpleDataSource" name="postgres"> <parameter name="serverName" type="java.lang.String" value="${MANAGEMENT_DATABASE_HOST}"/> <parameter name="portNumber" type="java.lang.Integer" value="${MANAGEMENT_DATABASE_PORT}"/> <parameter name="databaseName" type="java.lang.String" value="${MANAGEMENT_DATABASE_NAME}"/> <parameter name="user" type="java.lang.String" value="${MANAGEMENT_DATABASE_USER}"/> <parameter name="password" type="java.lang.String" value="${MANAGEMENT_DATABASE_PASSWORD}"/> <parameter name="loginTimeout" type="java.lang.Integer" value="30"/> <parameter name="socketTimeout" type="java.lang.Integer" value="15"/> <parameter name="prepareThreshold" type="java.lang.Integer" value="1"/> </persistence-instance>