3.10 glassfish-resources.xml
glassfish-resources.xml is the Java EE RI DD used to specify resource settings.
Description
glassfish-resources.xml is the DD used to specify resource settings that are unique to Java EE RI.
The root element of glassfish-resources.xml is resources. The element resources contains child elements and attributes, as indicated by "Element hierarchy". These child elements and attributes may further contain their child elements and attributes.
To create a JDBC connection pool, specify the following attributes based on the database to be connected:
-
Specify the following attributes to connect to Oracle:
Attribute
Value
Remark
The datasource-classname attribute of the /resources/jdbc-connection-pool element.
oracle.jdbc.pool.OracleDataSource
See #1.
oracle.jdbc.xa.client.OracleXADataSource
See #2.
The res-type attribute of the /resources/jdbc-connection-pool element.
javax.sql.DataSource
See #1.
javax.sql.XADataSource
See #2.
The connection-validation-method attribute of the /resources/jdbc-connection-pool element.
custom-validation
See #3.
The validation-classname attribute of the /resources/jdbc-connection-pool element.
org.glassfish.api.jdbc.validation.OracleConnectionValidation
See #3.
The /resources/jdbc-connection-pool/property element.
The value attribute in which the name attribute value is databaseName.
Oracle-SID
See #5.
The value attribute in which the name attribute value is serverName.
Oracle-host-name-or-IP-address
See #5.
The value attribute in which the name attribute value is portNumber.
port-number
See #5.
The value attribute in which the name attribute value is user.
user-name
-
The value attribute in which the name attribute value is password.
password
-
The value attribute in which the name attribute value is driverType.
thin
See #5.
The value attribute in which the name attribute value is url.
jdbc:oracle:thin:@Oracle-host-name-or-IP-address:port-number:Oracle-SID
See #5.
- #1:
-
Specify this if the XA transactions should not be used.
- #2:
-
Specify this if the XA transactions should be used.
- #3:
-
Specify this only if connection errors should be detected.
- #4:
-
This option specifies whether to enable the auto-commit functionality when the transaction is not a global transaction. If this is not true, connection errors are not detected normally. To detect connection errors, specify true.
- #5:
-
Specify the four properties (that is, databaseName, serverName, portNumber, and driverType) or the url. If you specify both, url takes effect. However, but the other four properties are ignored.
Schema
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions //EN" "http://glassfish.org/dtds/glassfish- resources_1_5.dtd">
Storage location
The DD file is stored in the following location:
-
application_ear_name/META-INF directory.
application_ear_name: Represents the archive name of the application.
-
war_name/WEB-INF directory.
war_name: Represents the archive name of the web application.
-
ejb_jar_name/META-INF directory.
ejb_jar_name: Represents the archive name of the ejb application.
-
client_jar_name/META-INF directory.
client_jar_name: Represents the archive name of the client application.
-
connector_rar_name/META-INF directory.
connector_rar_name: Represents the archive name of the connector module.
Element hierarchy
resources . custom-resource . . description . . property . external-jndi-resource . . description . . property . . . description . jdbc-resource . . description . . property . . . description . mail-resource . . description . . property . . . description . admin-object-resource . . description . . property . . . description . connector-resource . . description . . property . . . description . resource-adapter-config . . property . . . description . jdbc-connection-pool . . description . . property . . . description . connector-connection-pool . . description . . security-map . . . principal . . . . name . . . user-group . . . backend-principal . . property . . . description . work-security-map . . description . . principal-map . . group-map
Examples
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions //EN" "http://glassfish.org/dtds/glassfish- resources_1_5.dtd"> <resources> <jdbc-connection-pool> <property name="serverName" value="localhost"/> <property name="portNumber" value="1527"/> <property name="databaseName" value="forest"/> <property name="User" value="forest"/> <property name="Password" value="forest"/> <property name="URL" value="jdbc:oracle://localhost:1527/forest"/> </jdbc-connection-pool> <jdbc-resource enabled="true" jndi-name="jdbc/forest" pool-name="oracle_net_forest_forestPool"/> <connector-connection-pool associate-with-thread="false" connection-creation-retry-attempts="0" /> </resources>