• 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

Connecting to an Oracle 8i Database

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have searched through Java Ranch with no real answers to this question. So I post it here.
I get two errors when trying to connect to my local Oracle 8i Database when compiling my Java program. I am running this database on my laptop, affectionately called "laptop", running Windows 2000 Professional. My database is called "POS" with a username of "system" and a password of "manager".
Here are the two lines of code that give me errors right now...
Class.forName("oracle.jdbc.driver.OracleDriver");
- This one says "Exception java.lang.ClassNotFoundException must be caught, or it must be declared in the throws clause of this constructor"
Connection con;
con = DriverManager.getConnection("jdbc:oracle:thin:@laptop:1521:POS","system","manager");
- This one says "Exception java.sql.SQLException must be caught, or it must be declared in the throws of this constructor"
They both seem to be the same error with the caught and throws and such. Please enlighten me. My program is named POS.java and these commands are in the POS() function.
Anything else you need to know, just post and I will reply ASAP. Thanks!
~Jeff
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since they are "checked" exceptions, you must either enclose your code within a try/catch block, or declare that the method containing the code throws the exceptions.
Bosun

------------------
Bosun
SCJP for the Java� 2 Platform
 
Jeff Grant
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bosun Bello:
Since they are "checked" exceptions, you must either enclose your code within a try/catch block, or declare that the method containing the code throws the exceptions.


Got it, thanks! Now I just have to get my query to work.
[This message has been edited by Jeff Grant (edited December 20, 2001).]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic