wood burning stoves 2.0*
The moose likes Tomcat and the fly likes jdbc oracle hell Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "jdbc oracle hell" Watch "jdbc oracle hell" New topic
Author

jdbc oracle hell

Rowan Chattaway
Ranch Hand

Joined: Jan 18, 2002
Posts: 75
Hi,
I'm trying to create a jdbc racle:thin connection to a Oracle database through a jsp page. I'm using tomcat4.0 as my web server. My classpath is:
.;C:\jdk1.3;C:\jdk1.3\lib\classes.zip;c:\tomcat4.0\common\lib\servlet.jar;C:\oracle\ora81\jdbc\lib\classes12.zip
However when I run my jsp, I get the following:
Couldn't load database driver: oracle.jdbc.driver.OracleDriver
heres the code:
public String attemptConnection(String sql)
{
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc racle:thin:@147.89.124.140:1527 MS", "rowan", "rowan");
stmt = con.createStatement();
}
catch(ClassNotFoundException e)
{
return("Couldn't load database driver: " + e.getMessage());
}
catch(SQLException e)
{
return("SQLException caught: " + e.getMessage());
}
finally
{
try
{
if(con != null) con.close();
}
catch(SQLException ignored){}
}
return("connection appears to be fine...");
}
%>

if anyone can help, it will be much appreciated, as I've been trying to get this going to the hours now, and I'm near death! and I really need to get this done or my boss will get annoyed.......
Many thanks,
Rowan.


The early bird may get the worm, but the second mouse gets the cheese.........<br /> <br />Sun Certified Programmer for Java 2 Platform<br />Sun Certified Web-Component Developer for J2EE Platform
Rowan Chattaway
Ranch Hand

Joined: Jan 18, 2002
Posts: 75
I've just ported it to JDeveloper which has it's own oc4j environment - and it works fine. How do I get Apache tomcat to find and use the jdbc driver??
I'm guessing it's a classpath problem but I've set it.......unless apache isn't using CLASSPATH....?? confused...
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Tomcat 4.x does NOT use the system CLASSPATH.

You must place your classes12.zip file (the oracle drivers) into the <CATALINA_HOME>/common/lib directory. You should also rename it classes12.jar
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 566
Originally posted by Mike Curwen:
Tomcat 4.x does NOT use the system CLASSPATH.

You must place your classes12.zip file (the oracle drivers) into the <CATALINA_HOME>/common/lib directory. You should also rename it classes12.jar

Now why is that? I was confused by this when I first installed tomcat 4 and I found that the tomcat startup batch files do actually look like they are going to use the environment classpath, but then they just overwrite it instead.


I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I view it as a good thing.

It's part of an overall movement in the Java community to 'Just say No to System CLASSPATH'

Setting your own on the command line with -classpath solves way more problems than it ever creates. (in my experience)
Aarati More
Greenhorn

Joined: Feb 09, 2006
Posts: 3
Originally posted by Mike Curwen:
Tomcat 4.x does NOT use the system CLASSPATH.

You must place your classes12.zip file (the oracle drivers) into the <CATALINA_HOME>/common/lib directory. You should also rename it classes12.jar


Even i was facing the classdefinitionnotfound error with tomcat4.
So i followed the above suggested steps. But still it didn't work.
Finally i extract the classes12.zip. and i placed the 2 folders oracle and javax inside web-inf\classes. Then it started working.
Can anybody explain the reason behind this..
thanks
Bharat Roy
Ranch Hand

Joined: Jul 01, 2004
Posts: 156
Originally posted by Aarati More:
Originally posted by Mike Curwen:
...
So i followed the above suggested steps. But still it didn't work.
...


You also need to configure server.xml file of tomcat to make a connection pool. It will work fine then.
Michael Duffy
Ranch Hand

Joined: Oct 15, 2005
Posts: 163
Originally posted by Ankur Bhatt:


You also need to configure server.xml file of tomcat to make a connection pool. It will work fine then.


Why are you resurrecting a thread that is four years old?


%
Bharat Roy
Ranch Hand

Joined: Jul 01, 2004
Posts: 156
Originally posted by Michael Duffy:


Why are you resurrecting a thread that is four years old?


It was "Aarati More" not me. So ask this question to her.
Aarati More
Greenhorn

Joined: Feb 09, 2006
Posts: 3
Thanks Ankur...
Here i m placing part of my server.xml which is related to jdbc.
<Environment name="maxExemptions" type="java.lang.Integer"
value="15"/>
<Parameter name="context.param.name" value="context.param.value"
override="false"/>
<Resource name="jdbc/EmployeeAppDb" auth="SERVLET"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/EmployeeAppDb">
<parameter><name>user</name><value>user1</value></parameter>
<parameter><name>password</name><value>***</value></parameter>
<parameter><name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value></parameter>
<parameter><name>driverName</name>
<value>jdbc racle:thin:@161.121.32.43:1527 ev1spz</value></parameter>
</ResourceParams>
I do not know whether i have included everything properly or i need to modify the parameter enties.
As far as starting four year old thread is concerned, i think the age of the thread should not matter as long as there is fruitful technical discussion.
My intension was to use this thread as a refernce for the new discussion and problem i am facing.
But if it is against the forum policies then i have no problem in starting a new thread.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: jdbc oracle hell