• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Class.forName() for drive using Oracle 8i

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
jdbc:oracle:thin:@S0030947:1521:ispd1
jdbc:protocal:subprotocal:@host:port:sid

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