<?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.xmlCommand : 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-poolJDBC Connection pool jdbc/test-pool deleted successfullyCommand 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.xmlinstance1: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 cluster1jdbc/test-dsCommand list-jdbc-resources executed successfully.$ asadmin list-jdbc-connection-pools cluster1__TimerPoolDerbyPooljdbc/test-poolCommand list-jdbc-connection-pools executed successfully.$ asadmin delete-jdbc-connection-pool --cascade true --target cluster1 jdbc/test-poolCLI031 Warning: Option "target" is obsolete and will be ignored.JDBC Connection pool jdbc/test-pool deleted successfullyinstance1:JDBC Connection pool jdbc/test-pool deleted successfullyinstance2:JDBC Connection pool jdbc/test-pool deleted successfullyYou 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