JDBC datasources enable you to access data in a database server. You can create a new JDBC datasource, or edit an existing one.

About this task

A datasource defines a pool of JDBC connections that, in turn, connect to a specific database using a specified URL, username, and so on.

You can create two types of JDBC data sources:

Database Connection Pool Datasource

The Database Connection Pool (DBCP) datasource is the standard datasource provided by tc Runtime that uses the commons-dbcp package. Although this datasource is adequate for simple applications, it is single-threaded which means that, in order to be thread-safe, tc Runtime must lock the entire pool, even during query validation. As a result, the datasource is not suitable for highly concurrent environments. The datasource can also be slow, which can negatively affect the performance of Web applications.

Tomcat Datasource

The Tomcat datasource includes all the functionality of the DBCP datasource, but adds features to support highly-concurrent environments and multiple core/CPU systems. The Tomcat datasource typically performs much better than the DBCP datasource.

Additional features include:

  • Dynamic implementation of the interfaces, meaning that the datasource supports the java.sql and javax.sql interfaces for your runtime environment (assuming that is supported by your JDBC driver), even when compiled with a lower version of the JDK.

  • Validation intervals so that tc Runtime does not have to validate every time that the application uses the connection, which improves performance.

  • A Run-Once query, which is a configurable query that the tc Runtime instance runs only once when the connection to the database is established. This function is useful to configure session settings that you want to exist during the entire time the connection is established.

  • Ability to configure custom interceptors to enhance the functionality of the datasource. You can use interceptors to gather query stats, cache session states, reconnect the connection upon failures, retry queries, cache query results, and so on. The interceptors are dynamic and not tied to a JDK version of a java.sql/javax.sql interface.

  • Asynchjava.sqlronous connection retrieval that enables you to queue your request for a connection and receive a Future back.

Procedure

  1. Click the JDBC Data Sources link on the Resources tab of the tc Runtime configuration page.
  2. Select the action to perform.
    • To create a new data source, click Create a New Tomcat/DBCP Data Source.

    • To edit an existing data source, click its name in the table and make your changes.

  3. Click Save.

What to do next

Click Push in the Changes have been made locally window to write your changes to the tc Runtime configuration files. See Making Configuration Changes.