By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,195 Members | 954 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,195 IT Pros & Developers. It's quick & easy.

JDBC driver problem

P: n/a
Hello,

my Java-program can't load the JDBC driver.
I always get a java.lang.NoClassDefFoundError when I run it.

The JDBC Driver is in the directory: C:\programs\ora92\jdbc\lib

I think I have to set ORACLE_HOME environment variable and CLASSPATH,
but I have no idea how ?????????

Thanks

Axel
--------------------------------------------------
program:

import java.sql.*;

class Employee
{
public static void main (String args [])
throws SQLException
{
// Load the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

// Connect to the database
// You can put a database name after the @ sign in the connection URL.
Connection conn =
DriverManager.getConnection
("jdbc:oracle:oci8:@axel-0560nntbn1:1521:oracle", "scott", "tiger");

// Create a Statement
Statement stmt = conn.createStatement ();

// Select the ENAME column from the EMP table
ResultSet rset = stmt.executeQuery ("select ENAME from EMP");

// Iterate through the result and print the employee names
while (rset.next ())
System.out.println (rset.getString (1));

// Close the RseultSet
rset.close();

// Close the Statement
stmt.close();

// Close the connection
conn.close();
}
}
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
ad*******@web.de (Axel Dachtler) wrote in message news:<d6**************************@posting.google. com>...
Hello,

my Java-program can't load the JDBC driver.
I always get a java.lang.NoClassDefFoundError when I run it.

The JDBC Driver is in the directory: C:\programs\ora92\jdbc\lib

I think I have to set ORACLE_HOME environment variable and CLASSPATH,
You don't need ORACLE_HOME. To set CLASSPATH type in the same command session
where you want to execure java program:

SET CLASSPATH=C:\programs\ora92\jdbc\lib\classes12.zip

If CLASSPATH is set already (check it with "echo %CLASSPATH%" command)
use:
SET CLASSPATH=%CLASSPATH%;C:\programs\ora92\jdbc\lib\c lasses12.zip

Make sure you use correct name of the driver file.
but I have no idea how ?????????

Thanks

Axel
--------------------------------------------------
program:

import java.sql.*;

class Employee
{
public static void main (String args [])
throws SQLException
{
// Load the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

// Connect to the database
// You can put a database name after the @ sign in the connection URL.
Connection conn =
DriverManager.getConnection
("jdbc:oracle:oci8:@axel-0560nntbn1:1521:oracle", "scott", "tiger");

// Create a Statement
Statement stmt = conn.createStatement ();

// Select the ENAME column from the EMP table
ResultSet rset = stmt.executeQuery ("select ENAME from EMP");

// Iterate through the result and print the employee names
while (rset.next ())
System.out.println (rset.getString (1));

// Close the RseultSet
rset.close();

// Close the Statement
stmt.close();

// Close the connection
conn.close();
}
}

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.