Steven Erat's Blog Steven Erat Photography
 
 
Viewing By Entry
 
 

TalkingTree  Configuring the Oracle 10g Database Driver for ColdFusion MX

 

Oracle has recently released Oracle 10g Express Edition (XE), a free edition of their database server. While Macromedia supports connections to Oracle 10g from ColdFusion MX 7.01 using the built-in JDBC drivers that ship with ColdFusion, this version of Oracle is not officially supported with earlier versions including ColdFusion MX 7 or ColdFusion MX 6.x.

If you would like to connect an earlier version of ColdFusion MX to Oracle 10g, or would like to try an alternate driver if you're already using CFMX 7.01, then here is how to configure the 10g JDBC driver provided by Oracle for use with ColdFusion. This driver is often refered to as the Oracle Thin Client. Sometimes driver behavior varies between two vendors, so its often very helpful to try alternate driver versions.

  1. Obtain the Oracle 10g Release 2 JDBC driver from Oracle
    • If you already have Oracle 10g XE installed, then you can find the appropriate driver at oraclexe_root\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14.jar
    • You can also download the 10g R2 JDBC driver here.
  2. Copy the ojdbc14.jar to the standard J2EE web application custom library location for ColdFusion.
    • Server Configuration: CFusionMX7_root\wwwroot\WEB-INF\lib
    • JRun Configuration: JRun4_root\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\lib
  3. Restart the ColdFusion MX server
  4. Browse to the ColdFusion Administrator page for Data Sources.
  5. Choose a datasource name and select the driver option for Other. This datasource name is the alias you will use when specifying the value for the datasource attribute of CFQUERY.
  6. Provide the following information for the various fields:
    • JDBC URL: jdbc:oracle:thin:@[host]:1521:XE
      • The XE part here is the Oracle SID you wish to connect to. The SID defaults to XE but it may have been changed. Check tnsnames.ora in oraclexe_root\app\oracle\product\10.2.0\server\NETWORK\ADMIN
    • Driver Class: oracle.jdbc.OracleDriver
    • Driver Name: (optional: leave empty or provide custom name)
    • User Name
    • Password
  7. Click Submit on lower right
  8. If all goes will you will get a Verified message in green, but if there is any problem you will get a detailed error message in red font. The error is usually very precise and should help resolve the problem.
  9. You are now free to use this new ColdFusion Data Source in your web application.
  10. If using ColdFusion MX 7.01 you may want to configure another datasource for comparison using the Driver Option listed as "Oracle" in the drop down list. This will use the built-in driver supplied by ColdFusion that supports Oracle 10g.

If you are having trouble connecting from ColdFusion MX server, its often useful to try a pure Java test. To that end, I've created a Java program that will test the connection to the database outside of ColdFusion. The Java test executes the query the same way ColdFusion would when using the Oracle driver from Oracle, so its an apples to apples comparison. If the Java test produces the same error, at least you know that the problem is not in ColdFusion.

The self-contained test is here: JDBC Test for Oracle 10g.

To use it:

  1. download & unzip anywhere on the machine
  2. edit database.properties to set your host, username and password
  3. edit compileTest.bat and runTest.bat to set the JAVA_HOME variable for your system.
    (e.g., C:\CFusionMX7\runtime\jre or C:\j2sdk1.4.2_05)
  4. double click compileTest.bat to compile the Java source file
  5. double click runTest.bat to run the test

When running the test a command window will pop up and tell you to press any key to continue. When you do so, the program will attempt to load the database properties file, the database driver, make a database connection, and then run a query SELECT EDITION,VERSION FROM V$INSTANCE as a simple test.

You will either get a successful result or the same error as ColdFusion.

 


Comments

Hi Steven,

At step 2 you can also store ojdbc.jar/zip in another location and use CF Admin's 'Java and JVM' section to add this file to the ColdFusion Class Path.

This has the benefit of being able to keep all your JARs in one location so other apps can use them also.

The only gotcha here is that I have found I had to include the JAR directly in the CF class path - just adding the directory did not work.

cheers

David

C:\Oracle\jdbc\lib\ojdbc14.zip


That's true. You could choose to keep any custom jar files in one central location outside the application server root, and then point to them individually via the CF Classpath setting.

It is the J2EE convention though to keep custom web application jars in WEB-INF/lib and custom classes in WEB-INF/classes. So its a toss up between convention and convenience.


Steven,
When I try to compile compileTest.bat, I get an error: ORA-12505....
Here is how I configured the url: jdbc.url=jdbc:oracle:thin:@localhost:1521:GENS
My question is: do I type @localhost OR @servername ???

If it works, then can I use the same driver to connect to Oracle 9i, 8i, 7.3 ?

Eugene


You can do a pure java test inside coldfusion with cfml. Then cfdump the object and use the
methods to check the connection.


You can do a pure java test inside coldfusion with cfml. Then cfdump the object and use the
methods to check the connection.

oracle_thin = oracle.jdbc.OracleDriver.connect("jdbc:oracle:thin:@localhost:1521:GENS", props);

oracle_thin_Statement = oracle_thin.createStatement();

oracle_thin_Statement.close();
oracle_thin.close();


Hi Steven,

I have your approach for connecting to Oracle 10g (Rel. 2) successfully and was wondering whether the same approach could be followed for connecting Eclipse (WTP) to an Oracle database instance, I have already done this too successfully, however was curious as to whether this is the same approach.

Many thanks

Ethan Cane


Ethan, I'm sorry that I don't undertand your question. Specifically about connecting to Oracle from Eclipse WTP.


Ethan,

Are you looking for something like the DBEdit plug-in for Eclipse? (http://sourceforge.net/projects/dbedit)


Hi,

I have followed the steps mentioned by you on CFMX 6.1 dev box.
We also have Oracle 10g installed on the same machine.

I have created below SP in Oracle:
CREATE OR REPLACE PACKAGE Ravi_Pkg
IS
TYPE cursorType is ref cursor;

PROCEDURE Test (
   p_Merch_NUM    IN NUMBER,
   p_OUTCURSOR OUT cursorType
);

END Ravi_Pkg;
/
CREATE OR REPLACE PACKAGE BODY Ravi_Pkg
IS

-- Get Terms and Conditions Data based on ClientNum/PlatformNum/LanguageId
PROCEDURE test (
   p_Merch_NUM    IN NUMBER,
   p_OUTCURSOR OUT cursorType
)

IS

BEGIN
--p_OUTCURSOR cursorType;

OPEN p_OUTCURSOR FOR
      SELECT Item_num
      FROM TBL_MERCHANT_ITEMS
      WHERE MERCH_NUM = p_MERCH_NUM;
END test;

END Ravi_Pkg;
/

And granted ALL permissions to the one through whom I'm connecting.
After this I tried to execute below cfm code it is throughing the error can anyone please help me out.

   
   


Thank you,
Ravi.


 

 

Calendar

 
Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    

Search This Site

 
This is an exact search only

About This Site

 
Adobe Alumni & Community Professional. Expert in ColdFusion, Flex, LCDS, Photoshop, Lightroom. Linux RHCE. Follow Me!. For my photography check out Boston Portrait Photographer.
More about me

Recent Entries

 
ColdFusion 9.01 Server Monito..

Recent Comments

 
Posted By Swagat:
Ben Forta, best-selling ColdFusion author is coming to India this August at India's largest Adobe Flash Platform Conference. Ben Forta will conduct a ...

Posted By Steve:
The updated presentation I gave at CF.Objective() 2010 is available here: [link] At the end of the preso I gave a brief, pre-recorded demo of wri ...

Posted By Brad Munz:
I've come across a OOM problem in HotSpot which looks alot like this: java.lang.OutOfMemoryError: requested 4096000 bytes for GrET in /BUILD_AREA/jdk6 ...

recently played

 

no song is playing

now playing, a plug-in for itunes

Categories

 
RSS Adobe (34)
RSS Bicycling (9)
RSS Blogging (39)
RSS Books (13)
RSS Breeze (13)
RSS CFMX Podcasts (10)
RSS ColdFusion (429)
RSS Computer Technology (51)
RSS Events (26)
RSS Flex (20)
RSS Gadgets (10)
RSS HiTech Industry (16)
RSS Java (25)
RSS Learning (57)
RSS Linux (70)
RSS Mac OS X (22)
RSS Macromedia (27)
RSS Meetup (35)
RSS New England (62)
RSS Odds & Ends (25)
RSS Outdoors (32)
RSS Personal (29)
RSS Photos (111)
RSS Photoshop (29)
RSS Podcasts (18)
RSS Rants (19)
RSS Restaurants (8)
RSS Science (34)
RSS Spain (16)
RSS Travel (42)
RSS Twitter (10)
RSS Video (20)
RSS Webcam (3)
RSS Writing (10)

Blogs I Read

 
Terrence Ryan
Ben Forta
Ray Camden
Kinky Solutions
Dan Vega
Gary Gilbert
Simeon Bateman
Red Hat Blogs
O'Reilly Digital Media
O'Reilly Radar
John Nack
The Strobist
Scott Kelby
Matt Kloskowski
Joe McNally
Digital Photography School
Engadget
Science Blog

RSS

 


Add to Google
Add to My Yahoo!

Aggregated By

 


Aggregated by ColdFusionBlogger.org

Credits and Stuff

 
BlogCFC - Free ColdFusion Powered Blog Software
CJM Group - ColdFusion Website Hosting


 
 
blog | photos | flickr | referers | webcam | stats | about | contact
 
Copyright © 2010 Steven Erat. All rights reserved.
This is a personal weblog. The opinions expressed here represent my own and not those of my employer