permaculture playing cards*
The moose likes JDBC and the fly likes problem with jdbc drivers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "problem with jdbc drivers" Watch "problem with jdbc drivers" New topic
Author

problem with jdbc drivers

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
My jdbc program does not create a table with oracle8.
import oracle.jdbc.driver.*;
gives an error " opackage not found".
what are the system requirements .
please hepl.step by step will be easier.as i am new to jdbc
Suresh Selvaraj
Ranch Hand

Joined: Nov 14, 2000
Posts: 104
Hi,
Here are the steps for connecting to Oracle database.
1.import the standard classes like java.io.*, java.sql.*, java.util.*...
2.Load the oracle driver.
Class.forName("oracle.jdbc.driver.OracleDriver");
3.Establish Connection to the database...
Connection con;
con=DriverManager.getConnection("jdbcracle:thin:@localhost:1521:ORCL", "userid", "password");
localhost ==> is your host number.
4.Create statement object...
Statement s = con.createStatement();
5.Construct an sql query:
String query = "select * from EMPTABLE;
6.Execute the query...
ResultSet rs = s.executeQuery(query);
7.Retrieve the values from the ResultSet object...
if (rs != null) {
while(rs.next) {
String s1 = rs.getString(1);
String s2 = rs.getString(2);
.......
.......
}
}
if (con != null) {
try {
con.close();
}
catch(SQLException e1) {}
}
if ( s != null) {
try {
s.close();
}
catch(SQLException e1) {}
}

if ( rs != null) {
try {
rs.close();
}
catch(SQLException e1) {}
}

8.Statements 2 to 7 mentioned above should be in a try-catch-block.
try {
statements 2 thru 7
}
catch(SQLException e) {}
catch(ClassNotFounfException cnfe) {}
9.Ensure the ServerRoot\lib has the following libraries.
The ServerRoot\lib should have Servlet and JSP JAR files.
Also append the oracle.jar in the serverroot\lib classpath.
Hope this is in line with your requirements.
-
Suresh Selvaraj
[This message has been edited by Thomas Paul (edited March 21, 2001).]


Suresh Selvaraj, (author of JQuiz)<br />SCJP2<br /><a href="http://www.decontconsulting.com" target="_blank" rel="nofollow">www.decontconsulting.com</a>
 
Don't get me started about those stupid light bulbs.
 
subject: problem with jdbc drivers
 
Similar Threads
Loading file data into a DB2 table using java
WA #1.....word association
Need guidance for SCJD exam preparation
java sql parser
Need help to write a bot to collect data from internet.