• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

jdbc oracle hell

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rowan Chattaway
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Slime does not pay. Always keep your tiny ad dry.
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic