aspose file tools*
The moose likes JDBC 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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Oracle and Java Connectivity" Watch "Oracle and Java Connectivity" New topic
Author

Oracle and Java Connectivity

Prithiraj Sen Gupta
Ranch Hand

Joined: Sep 13, 2006
Posts: 92
Hello,

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
Marshal

Joined: May 26, 2003
Posts: 30764
    
156

Prithiraj,
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".


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, 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 204.170.55.201 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
Sheriff

Joined: Oct 27, 2005
Posts: 19722
    
  20

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


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Prithiraj Sen Gupta
Ranch Hand

Joined: Sep 13, 2006
Posts: 92
Hello,



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 "jdbcracle:thin:@eee.eee.ee.eee:1521:ORA10""

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: 14270
    
  21

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: http://aspose.com/file-tools
 
subject: Oracle and Java Connectivity