Wednesday, February 14, 2007

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 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">


Now you should be able to access the DataSource connecting to MySQL database with a JNDI location "jdbc/MyDS".

1 comment:

Anonymous said...

Hello,

In the latest build of OC4J and Oracle AS (10.1.3.3.0, July 2008) the contents of j2ee/home/applib directory is disabled, so it's not enough to put the mysql driver jar in that directory, you also have to edit the j2ee/home/application-deployments/ascontrol/orion-application.xml file and comment out the line with following tag:

remove-inherited name="global.libraries"

For more info, check this post on the Oracle OC4J forum: http://forums.oracle.com/forums/thread.jspa?messageID=2645102

Hope this will help other people,

Wouter