<?
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
name
=
"jdbc/test-pool"
res-type
=
"javax.sql.DataSource"
datasource-classname
=
"org.apache.derby.jdbc.ClientDataSource"
pool-resize-quantity
=
"1"
max-pool-size
=
"5"
steady-pool-size
=
"0"
statement-timeout-in-seconds
=
"60"
>
<
property
name
=
"serverName"
value
=
"localhost"
/>
<
property
name
=
"portNumber"
value
=
"1527"
/>
<
property
name
=
"dataBaseName"
value
=
"sun-appserv-samples"
/>
<
property
name
=
"User"
value
=
"APP"
/>
<
property
name
=
"Password"
value
=
"APP"
/>
<
property
name
=
"connectionAttributes"
value
=
";create=true"
/>
<
property
name
=
"driverType"
value
=
"4"
/>
</
jdbc-connection-pool
>
<
jdbc-resource
jndi-name
=
"jdbc/test-ds"
pool-name
=
"jdbc/test-pool"
/>
</
resources
>
To create the declared jdbc resources with GlassFish asadmin command
$ asadmin add-resources $HOME/glassfish-resources.xml
Command : JDBC connection pool jdbc/test-pool created successfully.
Command : JDBC resource jdbc/test-ds created successfully.
Command add-resources executed successfully.
To delete both resources:
$ asadmin delete-jdbc-connection-pool
--cascade true jdbc/test-pool
JDBC Connection pool jdbc/test-pool deleted successfully
Command delete-jdbc-connection-pool executed successfully.
To create, delete or list these jdbc resources in a cluster, simply add target option to the asadmin command:
$ asadmin add-resources --target cluster1 $HOME/glassfish-resources.xml
instance1:
Command : JDBC connection pool jdbc/test-pool created successfully.
Command : JDBC resource jdbc/test-ds created successfully.
instance2:
Command : JDBC connection pool jdbc/test-pool created successfully.
Command : JDBC resource jdbc/test-ds created successfully.
Command : JDBC connection pool jdbc/test-pool created successfully.
Command : JDBC resource jdbc/test-ds created successfully.
Command add-resources executed successfully.
$ asadmin list-jdbc-resources cluster1
jdbc/test-ds
Command list-jdbc-resources executed successfully.
$ asadmin list-jdbc-connection-pools cluster1
__TimerPool
DerbyPool
jdbc/test-pool
Command list-jdbc-connection-pools executed successfully.
$ asadmin delete-jdbc-connection-pool --cascade true --target cluster1 jdbc/test-pool
CLI031 Warning: Option "target" is obsolete and will be ignored.
JDBC Connection pool jdbc/test-pool deleted successfully
instance1:
JDBC Connection pool jdbc/test-pool deleted successfully
instance2:
JDBC Connection pool jdbc/test-pool deleted successfully
You can also create jdbc resources in GlassFish admin console, or via asadmin specifying command-line options. More details are in How to create jdbc connection pool and DataSource in GlassFish
Another usage of glassfish-resources.xml is to include it inside application, e.g., WEB-INF/glassfish-resources.xml for web app, META-INF/glassfish-resources.xml for ejb jar, etc. The declared resources are created upon deployment, and disposed of upon undeployment. More details in GlassFish embedded, JPA, EJB, DataSource and glassfish-resources.xml
Another usage of glassfish-resources.xml is to include it inside application, e.g., WEB-INF/glassfish-resources.xml for web app, META-INF/glassfish-resources.xml for ejb jar, etc. The declared resources are created upon deployment, and disposed of upon undeployment. More details in GlassFish embedded, JPA, EJB, DataSource and glassfish-resources.xml
Command delete-jdbc-connection-pool executed successfully.
No comments:
Post a Comment