my dog learned polymorphism*
The moose likes JDBC and the fly likes jdbc and oracle 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 "jdbc and oracle" Watch "jdbc and oracle" New topic
Author

jdbc and oracle

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I am trying to connect to oracle 8i using oracle 8.1.6 thin driver but with little luck. My computer environment is
WINNT 4.0.1
ORACLE 8i
JDK 1.2
ORACLE 8.1.6 OCI THIN DRIVER

can anybody help on the steps required to connect to oracle
All help appreciated
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi Valli
static{
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection ("jdbc racle:thin:@localhost:1521 rcl","scott","tiger");
}catch(Exception e){}
go to oracle sight /download section it will ask u to create a login ..creaTE IT THEN U WILL GET A LIST OF ALL DOWNLOADABLES
SELECT ORACLE JDBC DRIVER THEN U WILL GET THE LIST ALL THE DRIVER INFO DOWNLOAD JDBC-THIN 100%JAVA (CLASSES12.ZIP,1.5MB) (THIN DRIVER) FOR ORACLE
SET THE CLASS PATH FOR CLASSES12.ZIP FILE FOR U R CODE
THEN COMPILE U R CODE
IF U UNZIP THE FILE U CAN SEE THE SUB DIR ORACLE/JDBC/DRIVER/OracleDriver.class u need to set class path for oracle dir
"localhost" is u r machine & "1521" is a port number on which oracle service is running & "orcl" is host String
if u have any more problems u can mail me ravi_gali@hotmail.com
ravi
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi Valli
static{
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection ("jdbc racle:thin:@localhost:1521 rcl","scott","tiger");
}catch(Exception e){}
go to oracle sight /download section it will ask u to create a login ..creaTE IT THEN U WILL GET A LIST OF ALL DOWNLOADABLES
SELECT ORACLE JDBC DRIVER THEN U WILL GET THE LIST ALL THE DRIVER INFO DOWNLOAD JDBC-THIN 100%JAVA (CLASSES12.ZIP,1.5MB) (THIN DRIVER) FOR ORACLE
SET THE CLASS PATH FOR CLASSES12.ZIP FILE FOR U R CODE
THEN COMPILE U R CODE
IF U UNZIP THE FILE U CAN SEE THE SUB DIR ORACLE/JDBC/DRIVER/OracleDriver.class u need to set class path for oracle dir
"localhost" is u r machine & "1521" is a port number on which oracle service is running & "orcl" is host String
if u have any more problems u can mail me ravi_gali@hotmail.com
ravi
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Example code that work in on my machine...
WINNT 4.0
ORACLE 7.3.4
JDK 1.3 JDBC 2.0
ORACLE THIN DRIVER from CLASS111.ZIP (added to my CLASSPATH)
/*
A modified version of sample code provided by sun
Copyright 1997, 1998, 1999 Sun Microsystems, Inc. All Rights Reserved.
*/
<code>
import java.sql.*;

public class CreateCoffees {
public static void main(String args[]) {

String url = "jdbc racle:thin:@hostname:1521:sid";
Connection con;
String createString;
createString = "create table COFFEES " +
"(COF_NAME varchar(32), " +
"SUP_ID int, " +
"PRICE float, " +
"SALES int, " +
"TOTAL int)";
Statement stmt;

try {
Class.forName("oracle.jdbc.driver.OracleDriver");
}

catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,
"userid", "password");

stmt = con.createStatement();
stmt.executeUpdate(createString);

stmt.close();
con.close();

} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
</code>
Fyi, OCI my not be support by you driver...
Hope this helps...
Monty6

[This message has been edited by monty6 (edited September 11, 2000).]
 
Don't get me started about those stupid light bulbs.
 
subject: jdbc and oracle