Exercise: Test Data Access with Connection Pooling

Last modified by superadmin on 2018-01-12 20:28

Exercise: Test Data Access with Connection Pooling

This tutorial is yet unfinished.

Goal: Configure OC4J to use Connection Pooling for JDBC databases. 

Using MySQL with OC4J 10.1.3.x

When you have OracleXE available for free you would probably not use MySQL, but you may have a valid requirement to use MySQL with OC4J 10.1.3.

  1. Upload JDBC Driver You have to make JDBC drivers (e.g. mysql-connector-java-3.0.11-stable-bin.jar) for your database available to Oracle Application Server. You have to copy those to %ORACLE_HOME%/j2ee/home/applib directory.
  2. Create a Native DataSource. You can use the Application Server Control Console (ASC) to create a native data source as follows: 
jndi-name="jdbc/MyDS"
description="Native DataSource"
data-source-class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
user="user"
password="password"
url="jdbc:mysql://localhost:3306/mydatabase"
  1. Now you should be able to access the DataSource connecting to MySQL database with a JNDI location "jdbc/MyDS".

OC4J Connection Pooling and non-Oracle databases

  1. Consider using MySql database with OC4J. There is 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"/>
  1. You have to make sure that the factory-class in the connection-factory tag points to the DataSource class for your database.
Tags:
Created by Kalvis Apsītis on 2008-03-12 23:46
    
This wiki is licensed under a Creative Commons 2.0 license
XWiki Enterprise 6.4 - Documentation