Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

amir4oracle

Programmer
Nov 3, 2004
46
0
0
CA
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:eek:racle:eek:ci8:mad:oracle.world", "scott", "tiger");
Connection conn = DriverManager.getConnection("jdbc:eek:racle:thin@laptop:1521:eek:rcl", "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
rset.close();
sql_stmt.close();

// 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top