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 . Use 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:
Use the create-jdbc-resource subcommand in remote mode 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. 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 subcommands require a running server.
Create a JDBC resource by using the create-jdbc-resource(1) subcommand.
Information about properties for the subcommand is included in this help page.
If necessary, notify users that the new resource has been created.
This example creates a JDBC resource named DerbyPool.
asadmin> create-jdbc-resource --connectionpoolid DerbyPool jdbc/DerbyPool Command create-jdbc-resource executed successfully. |
You can also view the full syntax and options of the subcommand by typing asadmin help create-jdbc-resource at the command line.
Use the list-jdbc-resources subcommand in remote mode to list the existing JDBC resources.
Ensure that the server is running.
Remote subcommands require a running server.
List JDBC resources by using the list-jdbc-resources(1) subcommand.
This example lists JDBC resources for localhost.
asadmin> list-jdbc-resources jdbc/__TimerPool jdbc/DerbyPool jdbc/__default jdbc1 Command list-jdbc-resources executed successfully. |
You can also view the full syntax and options of the subcommand by typing asadmin help list-jdbc-resources at the command line.
You can enable or disable a JDBC resource by using the set subcommand. The JDBC resource is identified by its dotted name.
List JDBC resources by using the list-jdbc-resources(1) subcommand.
Modify the values for the specified JDBC resource by using the set(1) subcommand.
For example:
This example changes the res1 enabled setting to false.
asadmin>set resources.jdbc-resource.res1.enabled=false |
Use the delete-jdbc-resource subcommand in remote mode 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 subcommands require a running server.
List JDBC resources by using the list-jdbc-resources(1) subcommand.
If necessary, notify users that the JDBC resource is being deleted.
Delete a JDBC resource by using the delete-jdbc-resource(1) subcommand.
This example deletes a JDBC resource named DerbyPool.
asadmin> delete-jdbc-resource jdbc/DerbyPool Command delete-jdbc-resource executed successfully. |
You can also view the full syntax and options of the subcommand by typing asadmin help delete-jdbc-resource at the command line.