3.3.  Configure resources, for example, data sources, JNDI, class paths, J2C providers, as required by an application.


JDBC providers and data sources

A data source represents a real-world source of data, such as a relational database. When a data source object is registered with a JNDI naming service, an application can retrieve it from the naming service and use it to make a connection to the associated database.

Information about the data source and how to locate it, such as its name, the server on which it resides, its port number, and so on, is stored in the form of properties on the DataSource object. Storing this information in this manner makes an application more portable because it does not need to hard code a driver name, which often includes the name of a particular vendor. It also makes maintaining the code easier because if, for example, the data source is moved to a different server, all that needs to be done is to update the relevant property in the data source. None of the code using that data source needs to be touched.

To increase application performance and reduce workload on the database, connections to it are typical pooled. In other words, when the application closes the connection, the connection is returned to a connection pool, rather than being destroyed.

Data source classes and JDBC drivers are implemented by the data source vendor. By configuring a JDBC provider, you provide information about the set of classes that are used to implement the data source and the database driver. Also, you provide the environment settings for the DataSource object. A driver can be written purely in the Java programming language or in a mixture of the Java programming language and the Java Native Interface (JNI) native methods.

Steps to define access to a database

The following steps are involved in creating a data source:

  1. Verify that connection to the database server is supported by WebSphere Application Server.

  2. Ensure that the database is created and can be accessed by the systems that will use it.

  3. Ensure that the JDBC provider classes are available on the systems that will access the database. If you are not sure which classes are required, consult the documentation for the provider.

  4. Create an authentication alias that contains the user ID and password that will be used to access the database.

  5. Create a JDBC provider. The JDBC provider gives the class path of the data source implementation class and the supporting classes for database connectivity. This is vendor-specific.

    The information center provides information about JDBC driver support and requirements.

  6. Create a data source. The JDBC data source encapsulates the database-specific connection settings. You can create many data sources that use the same JDBC provider.

  7. Save the changes to the master repository and, in case it is a Network Deployment environment, synchronize with the nodes involved.

  8. Test the connection to the data source.

  9. Review and adjust the connection pool settings (do this on a periodic basis).

Professional hosting         Free 'Oracle Certified Expert Web Services Developer 6' Guide     Free SCDJWS 5.0 Guide