JDBC Connection basics (tearing my hair out!) [message #92307] |
Wed, 26 May 2004 04:33 |
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 #92506 is a reply to message #92503] |
Thu, 19 August 2004 13:03 |
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.
|
|
|