Monday, February 19, 2007

OC4J Connection Pooling and non-Oracle databases

In my last entry I blogged about using MySql database with OC4J. I provided an example of native datasource that connects to the MySql database. Native data sources do not use connection pooling capabilities of OC4J. If you want use OC4J connection pooling with third-party databases you have to use a managed data source.

Here is an example managed data source for MySql database.


<connection-pool name="test Connection Pool">
factory-class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"

user="user1"
password="user1"
url="jdbc:mysql://144.25.134.24/Test">
</CONNECTION-FACTORY>
</CONNECTION-POOL>

<managed-data-source>
connection-pool-name="test Connection Pool"
jndi-name="jdbc/mysql"
name="mysql"/>


You have to make sure that the factory-class in the connection-factory tag points to the DataSource class for your your database.



No comments: