Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Posts
    2

    Unanswered: JDBC - Oracle connection problem

    I could use some help!!! Java is new to me, so please forgive me....
    I'm making my first attempt to access a database.
    I have Oracle 9.0.1.1.1 database installed locally on my pc (Windows xp). I have J2SDK1.4.2_01 installed. And the classes12.zip file exists in C:\oracle\Ora9iDB\jdbc\lib.
    The entry in my tnsnames file is
    LOCAL =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = Donna_Johnston)(PORT = 1521))
    )
    (CONNECT_DATA =
    (SERVICE_NAME = local)
    )
    )
    ---I use this connection for SQLPlus

    I have tried a number of examples and am currently trying to use the following code:

    import java.sql.*;
    //import oracle.jdbc.*;

    public class JDBCtest {

    public static void main(String[] args)
    throws ClassNotFoundException,
    SQLException
    {
    Class.forName("oracle.jdbc.OracleDriver");
    String URL = "jdbc:oracle:thin:@Donna_Johnston:1521:local";
    Connection connection = DriverManager.getConnection(URL,
    "javaclass",
    "javaclass");;

    String SQLtext;
    SQLtext = "select userid from report_list";
    Statement statement = connection.createStatement();
    statement.close();
    connection.close();


    }
    }


    I get the following error messages:

    java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at JDBCtest.main(JDBCtest.java:22)
    Exception in thread "main"



    It seems like a Path issue, but this is my path:
    c:\j2sdk1.4.2_01bin;c:\oracle\Ora9iDB\bin;c:\oracl e\Ora9iDB\Apache\Perl\5.00503\bin\mswin32-x86;C:\Program Files\Oracle\jre\1.1.8\bin;%SystemRoot%\system32;% SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Common Files\Adaptec Shared\System;c:\oracle\Ora9iDB\jdbc\lib\classes12 .zip;c:\oracle\Ora9iDB\jdbc\lib\nls_charset12.zip;


    I sure could use any help offered!!

    thanks,
    Donna

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1

    Re: JDBC - Oracle connection problem

    Originally posted by johnsdh

    It seems like a Path issue, but this is my path:
    c:\j2sdk1.4.2_01bin;c:\oracle\Ora9iDB\bin;c:\oracl e\Ora9iDB\Apache\Perl\5.00503\bin\mswin32-x86;C:\Program Files\Oracle\jre\1.1.8\bin;%SystemRoot%\system32;% SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Common Files\Adaptec Shared\System;c:\oracle\Ora9iDB\jdbc\lib\classes12 .zip;c:\oracle\Ora9iDB\jdbc\lib\nls_charset12.zip;

    It's not a PATH issue; it's CLASSPATH issue. These two are different: PATH points to Windows executable files; CLASSPATH shows where the Java classes are located.

    Add the location of the Oracle class archive (C:\oracle\Ora9iDB\jdbc\lib) to the CLASSPATH variable.
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Nov 2003
    Posts
    2

    Thumbs up Re: JDBC - Oracle connection problem

    Originally posted by n_i
    It's not a PATH issue; it's CLASSPATH issue. These two are different: PATH points to Windows executable files; CLASSPATH shows where the Java classes are located.

    Add the location of the Oracle class archive (C:\oracle\Ora9iDB\jdbc\lib) to the CLASSPATH variable.


    Thanks!! That did it. I'm on my way now!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •