JDBC driver problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Axel Dachtler

    JDBC driver problem

    Hello,

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

    The JDBC Driver is in the directory: C:\programs\ora 92\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.r egisterDriver(n ew oracle.jdbc.dri ver.OracleDrive r());

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

    // Create a Statement
    Statement stmt = conn.createStat ement ();

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

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

    // Close the RseultSet
    rset.close();

    // Close the Statement
    stmt.close();

    // Close the connection
    conn.close();
    }
    }
  • Alex Filonov

    #2
    Re: JDBC driver problem

    adachtler@web.d e (Axel Dachtler) wrote in message news:<d6193773. 0312160407.39c4 5273@posting.go ogle.com>...
    Hello,
    >
    my Java-program can't load the JDBC driver.
    I always get a java.lang.NoCla ssDefFoundError when I run it.
    >
    The JDBC Driver is in the directory: C:\programs\ora 92\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:\pr ograms\ora92\jd bc\lib\classes1 2.zip

    If CLASSPATH is set already (check it with "echo %CLASSPATH%" command)
    use:
    SET CLASSPATH=%CLAS SPATH%;C:\progr ams\ora92\jdbc\ lib\classes12.z ip

    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.r egisterDriver(n ew oracle.jdbc.dri ver.OracleDrive r());
    >
    // Connect to the database
    // You can put a database name after the @ sign in the connection URL.
    Connection conn =
    DriverManager.g etConnection
    ("jdbc:oracle:o ci8:@axel-0560nntbn1:1521 :oracle", "scott", "tiger");
    >
    // Create a Statement
    Statement stmt = conn.createStat ement ();
    >
    // Select the ENAME column from the EMP table
    ResultSet rset = stmt.executeQue ry ("select ENAME from EMP");
    >
    // Iterate through the result and print the employee names
    while (rset.next ())
    System.out.prin tln (rset.getString (1));
    >
    // Close the RseultSet
    rset.close();
    >
    // Close the Statement
    stmt.close();
    >
    // Close the connection
    conn.close();
    }
    }

    Comment

    Working...