This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JDBC and the fly likes How to connect Oracle with Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to connect Oracle with Java " Watch "How to connect Oracle with Java " New topic
Author

How to connect Oracle with Java

Daniel William
Greenhorn

Joined: Nov 19, 2009
Posts: 4
I am completely new to Oracle with basic sql plus knowledge. I have installed Oracle 10g Release 2 and java 1.6 .
All i want to do is to connect Oracle with Java so that i can send queries and retrieve results. I found that we need a jdbc driver
and a odbc driver for connecting. How can i get them and how to install ? Or should i use another type of driver ?
Does Oracle have a server ?if yes , should I use it for accessing the database?

Can someone explain?

Thanks in advance.

Fatih Keles
Ranch Hand

Joined: Sep 01, 2005
Posts: 182
Daniel William wrote:I found that we need a jdbc driver
and a odbc driver for connecting. How can i get them and how to install ? Or should i use another type of driver ?

Oracle also distributes jdbc drivers : Oracle Jdbc Drivers
Daniel William wrote:
Does Oracle have a server ?if yes , should I use it for accessing the database? Can someone explain?

What kind of server do you expect? Do you mean a bundled application server with 10gR2 database setup? Please state it clearly. But in order to connect to database within your java code you don't need any server. Just have your database and tns listener running and follow any jdbc tutorial if necessary. This might be helpful for oracle specific how-to's : JDBC How-To Documents

Regards,

Fatih.
Daniel William
Greenhorn

Joined: Nov 19, 2009
Posts: 4
ok.i understood that i dont need a server to connect oracle with java.

i have created an Oracle database .

i have a java program which uses jdbc -odbc driver set for connecting it with Oracle.

there are 4 types of jdbc drivers . only one type can be used for connecting with odbc driver.
which type should i use and how can i configure it to work with odbc.?

i am just using a stand alone Java application program.

Fatih Keles
Ranch Hand

Joined: Sep 01, 2005
Posts: 182
Why don't you use jdbc thin driver? Why are you using odbc? Is it on purpose?

Regards,

Fatih.
Daniel William
Greenhorn

Joined: Nov 19, 2009
Posts: 4
its because i have used it in our lab session. i didnt have this difficulty of installing ,as it was set and configured by our admin.
i also did all programs using this driver set.
so to switch to thin driver i need learn about its syntax in java.

now whats the use of thin driver ? is it the right one for simple java programs?

Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

To turn your question on its head: what is the use of the JDBC-ODBC bridge? It is (by Sun's own admission) not what you would call a first choice for JDBC. If there is a vendor specific equivalent is is much easier to just use that.

The Orcale thin driver is a type 4 driver, so you need no extra configuration. I would always use it when working with Oracle.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to connect Oracle with Java
 
Similar Threads
JDBC driver confusion
JDBC using Oracle with Servlets
Coupling!!
How to connect Oracle with Java?
Connecting NT from Unix box via JDBC driver