Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to connect jdbc with oracle 8i?

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, i am thiru, i am unable to connect jdbc with oracle 8i.
can anyone help to do above mentioned problem.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
u can connect to Oracle through the JDBC-odbc bridge driver.
if u can connect to oracle from VB for example. u can connect useing the same dsn name.
rahul
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to get the current driver for your 8i database from Oracle (free download) and set your classpath to point to the classes111.zip (it's the same name for each version of Oracle but, won't reliably work with different versions) I personnally like the thin drivers instead of the OCI. Then to connect it's
try
{
//register the driver
DriverManager.registerDriver(new
oracle.jdbc.driver.OracleDriver());
// Get database connection.
Connection conn = DriverManager.getConnection(databaseURL,
userName, password);

}
catch (Exception ec)
{
System.out.println("Error on Connect " + ec + "\n");
}

the database url is
jdbc racle:thin:@[ip address or dns name for database]:[port of oracle listener]:[sid]

[This message has been edited by Carl Trusiak (edited June 13, 2000).]
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried exactly the same way as you said and when compiled with
'javac -classpath c:\oracle\ora81\jdbc\lib\classes111.zip myfile.java'
there was no error. But when I run it with
'java myfile '
I get the error
NoClassDefFound Error: oracle/jdbc/driver/OracleDriver.
What am I doing wrong.Please help
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You only included the classes111.zip file in the CLASSPATH when you compiled the program. You also need to include it when you run the program.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To Setup Oracle JDBC driverWin95/Win98/NT.
setLASSPATH=[oracle_home]\jdbc\lib\classes111.zip,[oracle_home]\jdbc\lib\nls_claset111.zip, %CLASSPATH%
(or)
setLASSPATH=[oracle_home]\jdbc\lib\classes12.zip,[oracle_home]\jdbc\lib\nls_claset12.zip, %CLASSPATH%
import oracle.sql.*;
import oracle.jdbc.drivers.*;
Hope this helps, monty6

[This message has been edited by monty6 (edited August 02, 2000).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic