Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class.forName() for drive using Oracle 8i

 
Brian Snyder
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Help!!! I'm new to JDBC and am trying to write/read to/from a database on Oracle. It's domain name is:snydb.database and sid:snydb.
Here's a snippet from my code. I keep geting
java.lang.ClassNotFoundException.

I some of this code from this web site, but can't seem to figure out what I'm missing. I'm just about ready to take my Java exam and am looking to pursue JDBC. I understand SQL, but just can't seem to get off the ground floor with this.
Please help!!! I tried using the Oracle web site and had trouble getting a straight answer.
Basically, what url do I use and how can I locate my driver so that I can write the proper class in Class.forName???
Thanks in advance.
[This message has been edited by Thomas Paul (edited April 12, 2001).]
 
prabhat kumar
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it has to be something like this ..
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection dbCon = DriverManager.getConnection("jdbc racle:thin:@address of machine:1521(port where it is listening):servicename", "scott","tiger");
if i use local oracle database then it is like this
Connection dbCon = DriverManager.getConnection("jdbc racle:thin:@localhost:1521:local", "scott","tiger");
hope it will help ;)
Prabhat kumar
[This message has been edited by Thomas Paul (edited April 12, 2001).]
 
Brian Snyder
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks prabhat,
I think my problem is that I'm not sure how to find out whether or not the following exist or how to obtain them???
1) @address of machine
2) port
3) servicename
4) "oracle.jdbc.driver.OracleDriver" How can I check for this?
I know these must seem like some really dunb questions, but I am making a career change and am new to it all. I've been reading O'Reilly JDBC and Java and they leave out how to find the above asked questions. Once I establish the connection and drivers, I am good to go!!!
Thanks for your patience.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The address of the machine and the port you should get from your DBA. Make sure that the OraacleDriver is on your classpath. If it is in a jar file, the jar file itself must be on the classpath. If it is exapanded then the directory up to but not including the "oracle" directory must be specified.
 
Monty Ireland
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simple java/jdbc/oracle example program using oracle's thin client. The driver name I have added to my classpath class111.zip.
<code>
import java.sql.*;
public class CreateCoffees {
public static void main(String args[]) {
String url = "jdbc racle:thin:@127.01.01: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>
hope this helps ...

------------------
Multi-Platform Database Developer ( on E.S.T. )

[This message has been edited by Monty Ireland (edited April 12, 2001).]
 
Brian Snyder
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know this is going to sound really dumb but where did you get the following information from? Please no jokes. ha!
jdbc racle:thin:@S0030947:1521:ispd1
 
Monty Ireland
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oracle DOC's... very little help!
Misc Web Pages... lots of code fragments...
Spend alot of time searching for one line of code!
jdbcracle:thin:@S0030947:1521:ispd1
jdbc:protocal:subprotocal:@host:port:sid

------------------
Multi-Platform Database Developer ( on E.S.T. )
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic