Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: JDBC java drivers + Oracle 8.1.7 + Red Hat 7.0

Re: JDBC java drivers + Oracle 8.1.7 + Red Hat 7.0

From: sdang <sdang_at_speakeasy.net>
Date: Wed, 1 Aug 2001 11:00:49 -0400
Message-ID: <tmg5uferbu3318@corp.supernews.com>

Yes thanks to Cindy this problem has been resolved. As long as the classes111.zip folder is included in the class path as well as the current directory, there's no need to unzip the class drivers.

export CLASSPATH=$ORACLE_HOME/jdbc/lib/classes111.zip:./

Also I was using the oci instead of the thin driver. Hope this helps anyone else experiencing these problems...

-Simon

"C. Ferguson" <c_ferguson_at_rationalconcepts.com> wrote in message news:3B673778.76E13731_at_rationalconcepts.com...
> No need to unzip the classes111.zip file. As long as it is specified in
 the
> -classpath option, java will look inside of it for the appropriate
 classes.
>
> Your problem is your are trying to use the oci driver which is not in the
 thin
> driver file.
>
> Change your getConnection syntax to use
> ...getConnection("jdbc:oracle:thin:@yourdbhostmachine:port:SID",
 dbuser,
> dbpassword);
>
> where yourdbhostmachine is the name of the machine where oracle
 instance
> resides. Can be the name or the IP address,
> port is the port that oracle is listening for TCP requests on,
 typically
> 1521, but you can check your listener.ora file,
> and SID is the name of the oracle instance you are trying to connect to.
 You
> can also find that in your listener.ora file.
>
> hth,
> cindy
>
> sdang wrote:
>
> > Thanks Cindy, I went ahead and unzipped the classes111.zip into the
 current
> > folder with my script, and the
> > Oracle driver was able to load!
> >
> > However now I am getting a different error:
> >
> > Exception in thread "main" java.sql.SQLException: Invalid Sytnax or
 Database
> > name is null
> > at

 oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:169)
> > at

 oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:211)
> > at

 oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:274)
> > at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:225)
> > at
> > oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:252)
> > at
> >

 oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:365)
> > at

 oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:260)

> > at java.sql.DriverManager.getConnection(DriverManager.java:517)
> > at java.sql.DriverManager.getConnection(DriverManager.java:177)
> > at QueryExample.main(QueryExample.java:13)
> >
> > I am just executing a select statement on the default EMP table with the
> > scott / tiger permissions (I can run the sql statment no problem within
> > sqlplus).
> >
> > I normally use Perl and perl DBI for databases, and I am new to Java and
> > JDBC for
> > database access. If anyone knows what small little configuration I
 need to
> > do, or what I may be doing wrong
> > please let me know. I've run some searches on google and Oracle and
 have
> > come up empty so far.
> >
> > Many Many thanks,
> > Simon
> >
> > here's the java code:
> > ---------------------------------------------------------------
> > import java.sql.*;
> >
> > class QueryExample
> > {
> > public static void main (String args [])
> > throws SQLException
> > {
> >
> > // Load the Oracle JDBC driver
> > DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
> >
> > // Connect to the database
> > Connection conn =
> > DriverManager.getConnection ("jdbc:oracle:oci8:",
> > "scott", "tiger");
> >
> > Statement stmt = conn.createStatement ();
> > ResultSet rset = stmt.executeQuery ("select ENAME from EMP");
> > while (rset.next ())
> > System.out.println (rset.getString (1));
> > }
> > }
> >
> > "C. Ferguson" <c_ferguson_at_rationalconcepts.com> wrote in message
> > news:3B66FDEF.C05872E2_at_rationalconcepts.com...
> > Hi,
> > try using the direct path to the oracle driver in your classpath
 option.
> > Also, you should include the current directory in the classpath option
 so
> > that your class file and any other supporting classes of yours will be
> > found.
> > e.g. java -classpath .:/export/opt/oracle/jdbc/lib/classes111.zip
 yourclass
> > where . tells java to look in your current directory, : separates the
> > different places you want java to search for required classes.
> > hth,
> > cindy
> > sdang wrote:
> > Hi, I am a newbie and trying to run the JdbcCheckup.java file included
 in
> > the samples and am getting the following error:
> > Exception in thread "main" java.lang.NoClassDefFoundError:
> > oracle/jdbc/driver/OracleDriver
> > at JdbcCheckup.main(JdbcCheckup.java:13)
> > I added to the Classpath:

 CLASSPATH:$oracle_home/jdbc/lib/classes111.zip
> > and compiled without any problems, but excuting the code (i.e. java
> > JdbcCheckup) gives me the above error.
> > I have also tried compiling and executing with the class path flags:
> > javac -cp $oracle_home/jdbc/lib/classes111.zip JdbcCheckup.java (no
 error)
> > java -classpath $oracle_home/jdbc/lib/classes111.zip (get above error)
> > Many thanks if you have any suggestions to put me on the right track.
> > -Simon
> > I am using:
> > ---------------------
> > Oracle 8.1.7
> > Red Hat 7.0
> > i386 machine
> > Jdk 1.3.1 from Sun
> > -------------------
> > Here's essentially my .bash_profile:
> >


> > ________________
> > # Get the aliases and functions
> > if [ -f ~/.bashrc ]; then
> > . ~/.bashrc
> > fi
> > export ORACLE_BASE=/db/u01/app/oracle
> > export ORACLE_HOME=/db/u01/oracle/product/8.1.7
> > export LD_LIBRARY_PATH=$ORACLE_HOME/jdbc/lib
> > export ORACLE_SID=ORA1
> > export ORACLE_TERM=ansi
> > export
> >

 PATH=$PATH:$ORACLE_HOME/bin:/usr/java/jdk1.3.1/bin:/usr/local/java/bin:/usr/
> > local/java/lib:/usr/java/jdk1.3.1/lib/tools.jar
> > export PATH=$PATH:usr/local/bin
> > export ORACLE_OWNER=oracle
> > TMPDIR=/var/tmp
> > export PATH TMPDIR
> > export CLASSPATH=/db/u01/oracle/product/8.1.7/jdbc/lib/classes111.zip
> > umask 022
> > ulimit -s 2048
> > #User specific environment and startup programs
> > PATH=$PATH:$HOME/bin
> > BASH_ENV=$HOME/.bashrc
> > export USERNAME BASH_ENV PATH
> >


> > ________________________
>
Received on Wed Aug 01 2001 - 10:00:49 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US