wood burning stoves 2.0
The moose likes JDBC and Relational Databases and the fly likes JDBC using Oracle with Servlets 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 "JDBC using Oracle with Servlets" Watch "JDBC using Oracle with Servlets" New topic

JDBC using Oracle with Servlets

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I am trying to access a database from Oracle through servlets.
I have a Oracle ODBC Driver in my ODBC32 , if I Add that driver it doesn't ask me for DSN, Description and a Database directory as I get in MS Access. I have given class and getconnection statements like below
Class.forName("oracle.jdbc.driver.Oracle ODBC Driver");
con=DriverManager.getConnection("jdbc racle:thin:cc939767-a:8080:ORCL","","");
I created a table with Oracle 8i . What else do I need?
Do I have to download some other driver ?
In getconnection I have given my computer name(cc939767-a:8080)and the port , is it correct?
Please help me with this .............

sah devine

[This message has been edited by Sah Devine (edited October 12, 2000).]
ARS Kumar
Ranch Hand

Joined: May 22, 2000
Posts: 108
I guess for Oracle you have to use the JDBC driver ( not the ODBC:JDBC driver ). You can get this from Oracle web site.
I am NOT sure this is the ONLY solution, but when I coded my servlet to connect to Oracle 8i I have used the JDBC driver.

ARS Kumar, Sun Certified Programmer for Java 2 Platform
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
Your URL is wrong:

con=DriverManager.getConnection("jdbc racle:thin:cc939767-a:8080:ORCL","","");

and should read
con=DriverManager.getConnection("jdbc racle:thin:@cc939767-a:8080:ORCL","","");
and most likely the port should be 1521 and not 8080, as this is the port used by Oracle, not the webserver or HTTP proxy.
And you indeed need the JDBC driver, version 8.1.6 or later (classes12.zip or newer).

Monty Ireland
Ranch Hand

Joined: Oct 03, 2000
Posts: 161
You need to find 'classes11.zip'. This file contains the oracle thin client drivers for jdk ver 1.2. Add this file to you CLASSPATH.
In you program... add the following code.
// localhost is ip address of host name
// portname is most often 1521
// sid or system id
// UID is user id
// PWD is password
String url = "jdbc racle:thin:@localhost :portname:sid";
con = DriverManager.getConnection(url, "UID", "PWD");
Hope this helps
p.s. There is more than one way to code the url for oracle THIN and OCI jdbc drivers. This URL format has work for me...
We learn more from our mistake's than from our success's.
[This message has been edited by Monty Ireland (edited October 13, 2000).]
[This message has been edited by Monty Ireland (edited October 13, 2000).]

Multi Platform Database Developer & DBA on E.S.T.
sairam angara

Joined: Jun 09, 2001
Posts: 1
download the thin drivers from the url : http://technet.oracle.com/software/tech/java/sqlj_jdbc/software_index.htm
and the code should be in the connection part should be
//(jdbc racle:thin:@systemname ort:sid withrespectto oracle);
conn = DriverManager.getConnection("jdbc racle:thin:@intranet:1521 racle","scott","tiger");

it will work.
I agree. Here's the link: http://aspose.com/file-tools
subject: JDBC using Oracle with Servlets
It's not a secret anymore!