A JDBC resource (data source) provides applications with a means of connecting
to a database through a connection pool. Typically, there is at least one JDBC
resource for each database accessed by an application deployed in a
domain. It is possible to have more than one JDBC resource for a
database.
A JDBC resource connects to a JDBC connection pool. If you have not already
created the JDBC connection pool, you can create it in the wizard while you are creating the
resource.
When you generate CMP entity beans from a database
or use the Enterprise Resources > Use Database command
to generate lookup code for a database, the JDBC data sources are generated automatically.
To create a JDBC resource:
Ensure the GlassFish application server is running.
Go to File > New (Ctrl-N).
In the Project drop-down list, choose either your EJB module or Web module.
Select GlassFish in the Categories pane, JDBC Resource in the File Types pane, and click Next.
Select an existing connection pool or create a new one.
(required) Enter a JNDI name for the resource.
Enable or disable the resource by choosing True or False.
Enter a description and click Next.
Enter any properties for the resource.
Click Finish.
To prepare to use a data source:
Ensure the GlassFish application server is running.
Create a web application and select the GlassFish Application Server as the target server.
Access the data source in, for example, a JSP page.
The resource is automatically registered when the project is deployed.
When you register the resource, the resource is available to all applications and resources.
For more on working with datasources,
see Chapter 5 Data Sources in the Oracle Containers for J2EE Services Guide: