aspose file tools*
The moose likes JDBC and the fly likes Connecting to an Oracle 8i Database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Connecting to an Oracle 8i Database" Watch "Connecting to an Oracle 8i Database" New topic
Author

Connecting to an Oracle 8i Database

Jeff Grant
Ranch Hand

Joined: Dec 19, 2001
Posts: 169
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("jdbcracle: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
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
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


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Jeff Grant
Ranch Hand

Joined: Dec 19, 2001
Posts: 169
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).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connecting to an Oracle 8i Database
 
Similar Threads
Basic help for a basic person
JDBC question!
Using Java ManagedBean and RMI to access methods on a server.
DriverManager.getConnection("...","user","password");
is CloneNotSupportedException Checked Exception.