File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases 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 and Relational Databases
Bookmark "Connecting to Oracle 7 thru jdbc" Watch "Connecting to Oracle 7 thru jdbc" New topic

Connecting to Oracle 7 thru jdbc

Rida Abrahams

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.


Fathima Khan
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
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 Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at for other WebSphere information.
Rida Abrahams

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());
System.out.println("JDBC driver loaded");

catch (ClassNotFoundException e) {

catch (SQLException e) {

and this is how I'm getting my connection:

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

I have imported these packages:
import javax.servlet.*;
import javax.servlet.http.*;
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?

Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
DriverManager.registerDriver (new 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

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

Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

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


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Connecting to Oracle 7 thru jdbc
It's not a secret anymore!