Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

This .java code is giving error as stated, kindly help me, thanks

This .java code is giving error as stated, kindly help me, thanks

This .java code is giving error as stated, kindly help me, thanks

The following code is giving only one error regarding the driver as stated at the end: (file name is jdbcconn.java)
The code selects empno, ename, sal from emp table and puts the data in an OS file Query1.lst

import java.sql.*;    // 1. Import JDBC Packages
    import java.io.*;

//    import oracle.jdbc.driver;
//    import oracle.sql;

public class jdbcconn
public static void main (String[] args) throws SQLException, IOException
    // 2. Load and register the jdbc driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

    // 3. Connecting to a Database
//    Connection conn = DriverManager.getConnection("jdbc:oracle:oci8:@oracle.world", "scott", "tiger");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin@laptop:1521:orcl", "scott", "tiger");

    // 4. Creating a Statement Object
Statement sql_stmt = conn.createStatement();

    // 5. Executing the Query and Returning a ResultSet
ResultSet rset = sql_stmt.executeQuery ("Select empno, ename, sal from emp");

    // 6. Process the result set,
    //      retrieve data in each row,
    //     column by column and write to an Operating System file
String str = "";
while (rset.next())    
    str += rset.getInt(1) + " " + rset.getString(2) + " " + rset.getFloat(3) + "\n";
byte buf[] = str.getBytes();

OutputStream fp = new FileOutputStream ("query1.lst");
fp.write (buf);
fp.close ();

    // 7. Closing the ResultSet and Statement

    // 8. Close the database connection
conn.close ();


C:\oracle\ora81\Apache\jdk\bin>javac jdbcconn.java
jdbcconn.java:13: Class oracle.jdbc.driver.OracleDriver not found.
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver
1 error

the compiler is showing the error "^" between driver and OracleDriver

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close