File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC 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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC using Oracle with Servlets" Watch "JDBC using Oracle with Servlets" New topic
Author

JDBC using Oracle with Servlets

Anonymous
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 .............

thanks
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.
Regards
ARSKumar


ARS Kumar, Sun Certified Programmer for Java 2 Platform
http://www.automatedsqa.com/
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).

42
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
Greenhorn

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
Class.forName("oracle.jdbc.driver.OracleDriver");
//(jdbc racle:thin:@systemname ort:sid withrespectto oracle);
conn = DriverManager.getConnection("jdbc racle:thin:@intranet:1521 racle","scott","tiger");

it will work.
------------------
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JDBC using Oracle with Servlets
 
Similar Threads
How to add oracle thin driver in NetBeans 5.0
Connecting Java Application with a Database
URGENT !! JDBC driver help. Reply asap
how to connect JDBC with oracle 9i
connection pooling