Home » Developer & Programmer » JDeveloper, Java & XML » JDBC Connection basics (tearing my hair out!)
JDBC Connection basics (tearing my hair out!) [message #92307] Wed, 26 May 2004 04:33 Go to next message
Ben Attwood
Messages: 4
Registered: May 2004
Junior Member
Hi

I have read the other answers relating to this on the forum but still have no success.

when trying to compile the following

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

class java_conn_v1 {
  public static void main (String args [[]]) throws SQLException
  {
        DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());

        Connection conn = DriverManager.getConnection
             ("jdbc:oracle:thin:@myHost:1521:myDb", "myUser", "myPass");
                             // @machineName:port:SID,   userid,  password

        Statement stmt = conn.createStatement();
        ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
        while (rset.next())
              System.out.println (rset.getString(1));   // Print col 1
        stmt.close();
  }
}

I get the following error:

java_conn_v1.java:2: package oracle.jdbc does not exist
import oracle.jdbc.*;
^
java_conn_v1.java:9: cannot resolve symbol
symbol  : class OracleDriver
location: package driver
        DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
                                                            ^

If I remove the import statement it says that the driver "new oracle.jdbc.driver.OracleDriver" cannot be resolved.

I have checked that my classpath holds the path to %ORACLE_HOME%jdbclib

Is this a problem with my java package 1.3.1 which I have sellected to use with Oracle 9i

Thanks in advance
Re: JDBC Connection basics (tearing my hair out!) [message #92335 is a reply to message #92307] Tue, 08 June 2004 14:07 Go to previous messageGo to next message
Wayne Shook
Messages: 1
Registered: June 2004
Junior Member
I downloaded the latest jdbc drivers and they had new ones for 9i.

Not sure that is your problem but it could be.

Good luck. I didn't have much hair to pull out or I would have.
Re: JDBC Connection basics (tearing my hair out!) [message #92503 is a reply to message #92307] Wed, 18 August 2004 17:31 Go to previous messageGo to next message
Krithiga
Messages: 2
Registered: August 2004
Junior Member
I am trying it too. Please let me know what you did if you were successful. I also get ClassNotFoundException when I try to use Class.ForName instead of DriverManager.getConnection().
Re: JDBC Connection basics (tearing my hair out!) [message #92506 is a reply to message #92503] Thu, 19 August 2004 13:03 Go to previous message
Ben Attwood
Messages: 4
Registered: May 2004
Junior Member
The advice given to me was double check your paths.
Mine have been set like this

set JAVA_HOME=C:jdk1.3.1
set ORACLE_HOME=C:oracleora92
set PATH=.;%PATH%;%JAVA_HOME%bin;%ORACLE_HOME%bin
set CLASSPATH=.;%JAVA_HOME%;%JAVA_HOME%lib;%JAVA_HOME%libtools.jar;%ORACLE_HOME%jdblibclasses12.zip;%ORACLE_HOME%jdbclibnls_charset12.zip;

the oracledriver class for me was in /oracle/jdbc/driver

With regards to your Class.ForName if you are using it on Microsoft JVM it will not work otherwise check your paths.
Previous Topic: tree structure retreiving for oracle DB
Next Topic: Re: sdfs
Goto Forum:
  


Current Time: Wed Apr 24 18:36:48 CDT 2024