A JDBC resource, also known as a data source, provides an application with a means of connecting to a database. Typically, you create a JDBC resource for each database that is accessed by the applications deployed in a domain. Multiple JDBC resources can be specified for a database.
A JDBC resource is created by specifying the connection pool with which the resource will be associated . Unse a unique Java Naming and Directory Interface (JNDI) name to identify the resource. For example, the JNDI name for the resource of a payroll database might be java:comp/env/jdbc/payrolldb.
The following tasks and information are used to administer JDBC resources:
The remote create-jdbc-resource command enables you to create a JDBC resource. Creating a JDBC resource is a dynamic event and does not require server restart.
Because all JNDI names are in the java:comp/env subcontext, when specifying the JNDI name of a JDBC resource in the Administration Console, use only the jdbc/name format is used. For example, a payroll database might be specified as jdbc/payrolldb.
Before creating a JDBC resource, you must first create a JDBC connection pool. For instructions, see To Create a JDBC Connection Pool.
Ensure that the server is running.
Remote commands require a running server.
Create a JDBC resource by using the create-jdbc-resource(1) command.
If necessary, notify users that the new resource has been created.
The following example command creates a JDBC resource named DerbyPool:
asadmin create-jdbc-resource --connectionpoolid DerbyPool jdbc/DerbyPool |
Information similar to the following is displayed if the connection pool is usable:
Command create-jdbc-resource executed successfully. |
To see the full syntax and options of the command, type asadmin create-jdbc-resource --help at the command line.
The remote list-jdbc-resources command enables you to list the existing JDBC resources.
Ensure that the server is running.
Remote commands require a running server.
List JDBC resources by using the list-jdbc-resources(1) command.
The following example command lists JDBC resources for localhost:
asadmin list-jdbc-resources |
Information similar to the following is displayed:
jdbc/__TimerPool jdbc/DerbyPool jdbc/__default jdbc1 Command list-jdbc-resources executed successfully. |
To see the full syntax and options of the command, type asadmin list-jdbc-resources --help at the command line.
This remote command enables you to delete an existing JDBC resource. Deleting a JDBC resource is a dynamic event and does not require server restart.
Before deleting a JDBC resource, all associations with this resource must be removed.
Ensure that the server is running.
Remote commands require a running server.
Obtain the exact name of the JDBC resource that you are deleting.
To list the existing JDBC resources:
asadmin list-jdbc-resources |
If necessary, notify users that the JDBC resource is being deleted.
Delete a JDBC resource by using the delete-jdbc-resource(1) command.
The following example command deletes a JDBC resource named DerbyPool:
asadmin delete-jdbc-resource jdbc/DerbyPool |
Information similar to the following is displayed:
Command delete-jdbc-resource executed successfully. |
To see the full syntax and options of the command, type asadmin delete-jdbc-resource --help at the command line.