aspose file tools*
The moose likes JDBC and the fly likes Connecting to Oracle 7 thru jdbc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Connecting to Oracle 7 thru jdbc" Watch "Connecting to Oracle 7 thru jdbc" New topic
Author

Connecting to Oracle 7 thru jdbc

Rida Abrahams
Greenhorn

Joined: Jan 25, 2004
Posts: 23
Hi there,

Can anyone tell me how to connect to an Oracle 7 database using jdbc?
I've got the correct jdbc drivers. I can connect to the database fine if I connect within a normal java application from the command line.
But as soon as I connect within a servlet I get a "No suitable driver found" exception.

Please help.

Thanks

Fathima Khan
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
You'll need to tell us what Servlet container you are using in order for us to help you. Also, which drivers you are using and how you set them up in the container would be useful to know as well.

Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Rida Abrahams
Greenhorn

Joined: Jan 25, 2004
Posts: 23
Hi there again,

Thanks for the reply. I am running Tomcat 4 on Linux Redhat 6. I am not sure how the database administrator set the drivers up or which drivers I am using.
I do know that by testing the database connection using a normal java program from the command line does work and does return data from the oracle database.

here is the init method where i am specifying the driver name:

public void init() {

try {
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("JDBC driver loaded");
}

catch (ClassNotFoundException e) {
System.out.println(e.toString());
}

catch (SQLException e) {
System.out.println(e.toString());
}
}

and this is how I'm getting my connection:

Connection con = DriverManager.getConnection("jdbc racle:thin:@192.96.74.6:1521:bndb", "sb", "sb");

I have imported these packages:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;

I don't know if any of this info will be helpful in determining which drivers I am using though. Someone told me that I needed to add the location of the jdbc drivers to my Java classpath and my Tomcat classpath. Do you know if that is correct?

Thanks.
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
Class.forName("oracle.jdbc.driver.OracleDriver");


Why are you registering drivers 2 times? Its enough to write

DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
Connection con = DriverManager.getConnection();
Francis Amanfo
Ranch Hand

Joined: Nov 02, 2003
Posts: 44
Hi,

Are you sure you have dropped Oracle's JDBC driver in your WEB-INF/libs?

Regards,
Francis
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

OK, time to move this to a more appropriate forum.

This forum is for Servlets questions.

I will move this thread to the JDBC forum

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connecting to Oracle 7 thru jdbc