This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Oracle and Java Connectivity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Oracle and Java Connectivity" Watch "Oracle and Java Connectivity" New topic

Oracle and Java Connectivity

Prithiraj Sen Gupta
Ranch Hand

Joined: Sep 13, 2006
Posts: 92

I am using Java6 and trying to connect to Oracle 10 DB in the same system. What should I write inside Class.forName() to get connected with oracle database using thin client?

I have written

But the Catch statements got executed.

Thanks & Regards

Prithiraj Sen Gupta
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32815

The string depends on what driver you are using. For example, if you are using the Oracle thin driver, it would be "oracle.jdbc.driver.OracleDriver".

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Prithiraj Sen Gupta
Ranch Hand

Joined: Sep 13, 2006
Posts: 92
Thanks Jeanne.

The Problem got over.

Now Facing problem in the connection string.

Here is the TCP/IP address of the system I am using.
1521 is the Port number and ORA10 is the database name.

But I couldn't able to connect to the database.
[ December 18, 2007: Message edited by: Prithiraj Sen Gupta ]
Rob Spoor

Joined: Oct 27, 2005
Posts: 20183

What's the error message? Are you supplying the right login information?

How To Ask Questions How To Answer Questions
Prithiraj Sen Gupta
Ranch Hand

Joined: Sep 13, 2006
Posts: 92

The above line is Executed.

Sorry Jeanne for my Post where I have mentioned it was showing error. It was only for the fact that I have typed jdbcOdbcDriver inplace of JdbcOdbcDriver

The following line of code is not getting executed

ServerName, UserID and PassWord are all correct.

The Error is : " No suitable driver found for """

I tried with "oracle.jdbc.driver.OracleDriver" too
its firing ClassNotFoundException
[ December 18, 2007: Message edited by: Prithiraj Sen Gupta ]
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15037

As Jeanne said, if you want to use the Oracle thin driver (as your connection string suggests), you should use "oracle.jdbc.driver.OracleDriver" instead of "sun.jdbc.odbc.JdbcOdbcDriver", and you must put the JDBC driver JAR file in the classpath (otherwise you'll get the ClassNotFoundException).

You can download the Oracle JDBC driver on this page on Oracle's website.
[ December 20, 2007: Message edited by: Jesper Young ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: Oracle and Java Connectivity
It's not a secret anymore!