Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

help needed with oci jdbc driver on Oracle 8.1.5

13 views
Skip to first unread message

Bing Zheng

unread,
Jun 12, 2000, 3:00:00 AM6/12/00
to
The following code (slightly modified oracle oci example) works on Solaris
but not Win NT. Same version of jdk (1.2.2) and JDBC Driver (oracle 1.2)
were used. (I added the [oracle home]\lib directory to the PATH on winnt
per instruction.)

When i run it on NT, i got the following exception error. Can someone tell
me what's going on? Thanks in advance!
Exception in thread "main" java.lang.UnsatisfiedLinkError: make_c_state
at oracle.jdbc.oci8.OCIDBAccess.make_c_state(Native Method)
at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:214)
at
oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:198)

at
oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:251)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:224)
at java.sql.DriverManager.getConnection(DriverManager.java:517)
at java.sql.DriverManager.getConnection(DriverManager.java:199)
at JdbcCheckup.main(JdbcCheckup.java:19)

---Code Listing---
// You need to import the java.sql package to use JDBC
import java.sql.*;
import java.io.*;
import java.math.*;
import oracle.jdbc.driver.*;
import oracle.sql.*;

class JdbcCheckup
{

public static void main (String args [])
throws SQLException, IOException
{

// Load the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

System.out.println ("Connecting...");
Connection conn = DriverManager.getConnection ("jdbc:oracle:oci8:@tnsname",
"username", "password");
// Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@servername:1521:dbname","username", "password");

System.out.println ("connected.");

// Create a statement
Statement stmt = conn.createStatement ();

// Do the SQL "Hello World" thing
ResultSet rset = stmt.executeQuery ("select 'Hello World' from dual");

while (rset.next ())
System.out.println (rset.getString (1));
// close the result set, the statement and connect
rset.close();
stmt.close();
conn.close();
System.out.println ("Your JDBC installation is correct.");
}

}

BARRIE TAYLOR

unread,
Jul 11, 2000, 3:00:00 AM7/11/00
to Bing Zheng
I'm having very similar problems, using Oracle 7.3.4 on win98.

Also noted you need to start the oracle listeners to get a connection on
port 1521.

My program and key parameters are detailed in the attached two files, I
included some reference points since there are a few things to check in
the oracle configuration etc.

One thing I am not sure of is how to check the .dll files included in the
oracle driver distribution for windows are being found by the driver
package.

Also does anyone know how to setup ODBC:JDBC connection to Oracle? It
might turn out to be easier to get that working instead... (tho loess
preferable)

import java.sql.*;
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
//import oracle.*;//this line inserted resolve classpath problem.
//import oracle.jdbc.driver.OracleDriver;
/*
Create new project.
*/
public class ConnectOraclewithclasses111 extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException,IOException
{
PrintWriter out = res.getWriter();
res.setContentType("text/html");
out.println("setting up variables in ConnectOraclewithclasses111 using oci7 driver, Tues 11-Jul, 33<BR>");
// define query string.
String sql1 = "select * from dual";
try
{ //open data base connection.
out.flush();
out.println("registering driver for connection to database.<BR>");
Class.forName("oracle.jdbc.driver.OracleDriver");
//DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
out.println("class registered, getting connection.<BR>");
Connection m_connection = DriverManager.getConnection
("jdbc:oracle:oci7:@SID1","scott", "tiger");
// ("jdbc:oracle:thin:@ORCL","scott", "tiger");
// ("jdbc:oracle:oci7:@ORCL","scott", "tiger");
out.println("Connection to database succeeded.<BR>");
Statement stmt = m_connection.createStatement();
out.println("stmt created.<P>");
stmt = m_connection.createStatement();
try
{ // try Z2, run query to check if userid & password are valid.
out.println("executing sql1 ="+sql1+"<BR>");
ResultSet rs = stmt.executeQuery(sql1);
out.println("sql executed.<BR>");
if (rs.next()) // if Z3-ValidUser
{
out.println("non null set returned by query.<BR>");
}//
else
{
out.println("Invalid userID or Password, please try again.");
}
}//
catch(Exception ex){ //Trap SQL errors
out.println("Error selecting on userid.<BR>"+ex.toString()+"<br>" + System.getProperties());} // end try Z2
stmt.close();
m_connection.close();
} // first try catching classnot found error.
// catch(ClassNotFoundException ex){ //
// out.println("Error loading driver class. Exception information<BR>"+ex.toString()+
// "<br><br>System information.<br>" + System.getProperties());
// }// catch all other errors.
catch(Exception ex){ //
out.println("Error connecting to database. Exception information<BR>"+ex.toString()+
"<br><br>System information.<br>" + System.getProperties());
}//
out.println("</body></html>");
} // end doGet
}

I'm pretty sure this is a java classpath type problem, but have run out of ideas.

I have been playing with apache/java servlets using jdbc connections to Oracle. At uni I had it working on Oracle8/Sun OS, also have a working installation on Oracle8/Redhat6.1 .

At the moment I am trying to get a similar configuration workin on a windows platform. I am using the following packages.
Personal Oracle7 Release 7.3.4.0.0 - Production Release
Apache/1.3.12 (win32) Apache Jserv/1.1.2
jdk1.1.8

I have tested the Apache/Jserv configuration (IsItWorking loads no problem), even had jdbc/odbc connections working communicating with MSaccess.

I am getting
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

I am using the classes111.zip driver for windows. (NB it is written for jdk1.1.1, I'm using jdk1.1.8 is that an issue?)
my java classpath is
c:\myweb\jdk1.1.8\lib\classes.zip; #standard part of jdk library
C:\myweb\jsdk2.0\lib\jsdk.jar; #required for Jserv
C:\myweb\data\classes111.zip #required for jdbc bridge to Oracle.

The dll files OCI73JDBC.DLL and oci73jdbc_g.dll (not sure if the 2nd dll is required) have been manually copied across to c:\orawin95\bin directory. I also tried using only one of the dll's at a time, I havent found anything that says anything other than the dll's should be placed in the windows path.

using winzip to view the contents of classes111.zip shows that oracle\jdbc\driver\OracleDriver.class exists within the classes111.zip file.

The Oracle jdbc howto I looked at suggested using the lines below.

import java.sql.*;
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection ("jdbc:oracle:oci7:@mydatabase","scott", tiger");

The full java file is attached below.

the Servlet runtime error message is here, a couple of things that dont make sense to me
- classpath as printed in the error message thrown does not show classes111.zip even though it shows when compiling.
setting up variables in ConnectOraclewithclasses111 using oci7 driver, Tues 11-Jul, 33
registering driver for connection to database.
Error connecting to database. Exception information
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

System information.
{user.language=en, java.home=C:\MYWEB\JDK1.1.8\BIN\.., java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, awt.toolkit=sun.awt.windows.WToolkit, file.encoding.pkg=sun.io, java.version=1.1.8, file.separator=\, line.separator= , user.region=US, file.encoding=Cp1252, java.compiler=symcjit, java.vendor=Sun Microsystems Inc., user.timezone=AET, user.name=mat, os.arch=x86, os.name=Windows 95, java.vendor.url=http://www.sun.com/, user.dir=C:\WINDOWS\Profiles\mat\Desktop, java.class.path=c:\myweb\jserv\ApacheJServ.jar;c:\myweb\jsdk2.0\lib\jsdk.jar;C:\MYWEB\JDK1.1.8\BIN\..\classes;C:\MYWEB\JDK1.1.8\BIN\..\lib\classes.zip;C:\MYWEB\JDK1.1.8\BIN\..\lib\classes.jar;C:\MYWEB\JDK1.1.8\BIN\..\lib\rt.jar;C:\MYWEB\JDK1.1.8\BIN\..\lib\i18n.jar, java.class.version=45.3, os.version=4.10, path.separator=;, user.home=C:\MYWEB\JDK1.1.8\BIN\..}

The java classpath shown when compiling is shown below from the kawa compile message below.
c:\myweb\jdk1.1.8\bin\javac.exe ConnectOraclewithclasses111.java
Class Path - .;C:\Program Files\Kawa\classes.zip;c:\myweb\jdk1.1.8\lib\classes.zip;C:\myweb\jsdk2.0\lib\jsdk.jar;C:\myweb\data\classes111.zip
File Compiled...
No Errors...

the classpath as defined in kawa > packages > classpath is
C:\myweb\jsdk2.0\lib\jsdk.jar;C:\myweb\data\classes111.zip;

What I dont understand is how/why the code doesnt need an "import oracle.*;" line in the java code since servlets need the jsdk.jar file in the classpath and
import javax.servlet.*;
import javax.servlet.http.*;
to load the servlet drivers.


I looked at tnsnames.ora to find the "SID" for my system, chose ORCL. left the password as scott/tiger.

Any ideas??

I have attached below screendumps and the key configuration files from the major packages, maybe there is something obvious there.

This is screendump from starting Oracle windows client.
SQL*Plus: Release 3.3.4.0.0 - Production on Fri Jul 07 10:54:41 2000
Copyright (c) Oracle Corporation 1979, 1996. All rights reserved.
Connected to:
Personal Oracle7 Release 7.3.4.0.0 - Production Release
With the distributed and replication options
PL/SQL Release 2.3.4.0.0 - Production

this is screendump from starting oracle listener,

LSNRCTL for 32-bit Windows: Version 2.3.4.0.0 - Production on 07-JUL-00 10:54:19
Copyright (c) Oracle Corporation 1994. All rights reserved.
Starting tnslsnr: please wait...
TNSLSNR for 32-bit Windows: Version 2.3.4.0.0 - Production
System parameter file is C:\ORAWIN95\network\admin\listener.ora
Log messages written to C:\ORAWIN95\network\log\listener.log
Listening on: (ADDRESS=(PROTOCOL=tcp)(DEV=124)(HOST=127.0.0.1)(PORT=1521))
Connecting to (ADDRESS=(PROTOCOL=TCP)(Host=localhost)(Port=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 32-bit Windows: Version 2.3.4.0.0 - Production
Start Date 07-JUL-00 10:54:23
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security OFF
SNMP OFF
Listener Parameter File C:\ORAWIN95\network\admin\listener.ora
Listener Log File C:\ORAWIN95\network\log\listener.log
Services Summary...
ORCL has 1 service handler(s)
The command completed successfully

the tnsnames.ora file is below for reference.

#This is a SQL*Net Configuration file generated by SQL*Net Easy Configuration.
#Attention: Do not modify this file yourself.
#If you do, your SQL*Net Easy Configuration may not function properly.

Example1.world =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(COMMUNITY = tcp.world)
(PROTOCOL = TCP)
(Host = Production1)
(Port = 1521)
)
)
(CONNECT_DATA = (SID = SID1)
)
)
Example2.world =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(COMMUNITY = spx.world)
(PROTOCOL = SPX)
(Service = Server_lsnr)
)
)
(CONNECT_DATA = (SID = ORCL)
)
)
Example3.world =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(COMMUNITY = nmp.world)
(PROTOCOL = NMP)
(Server = FinanceServer1)
(Pipe = ORAPIPE)
)
)
(CONNECT_DATA = (SID = ORCL)
)
)
Tcp-loopback.world =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(COMMUNITY = tcp.world)
(PROTOCOL = TCP)
(Host = 127.0.0.1)
(Port = 1521)
)
(ADDRESS =
(COMMUNITY = tcp.world)
(PROTOCOL = TCP)
(Host = 127.0.0.1)
(Port = 1526)
)
)
(CONNECT_DATA = (SID = ORCL)
)
)
Beq-Local.world =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(COMMUNITY = beq.world)
(PROTOCOL = BEQ)
(PROGRAM = oracle73)
(ARGV0 = oracle73ORCL)
(ARGS = '(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))')
)
)
(CONNECT_DATA = (SID = ORCL)
)
)
MAtt

par...@my-deja.com

unread,
Jul 12, 2000, 3:00:00 AM7/12/00
to
Matt/Barrie:

1. The Oracle documentation states that you need the following two
import statements.
import java.sql.*;
import java.math.*;

2. The classpath problem you've gotten around with by importing
oracle.* and oracle.jdbc.driver.OracleDriver would have better been
solved by adding the classes111.zip file to the classpath.

3. The import statement is used for resolving shorten class names.
When you use the full class name then no import statement is required.
e.g.

- references to the JFrame class are usually preceeded by "import
javax.swing.*;"
- if you reference javax.swing.JFrame then the import statement is
not required.
- thus "DriverManager.registerDriver (new
oracle.jdbc.driver.OracleDriver());" also does not require an import
statement.

4. To use OCI to access an oracle database on your workstation, try
either of the following getConnection statements:

m_connection = DriverManager.getConnection("jdbc:oracle:oci7:@Tcp-
loopback","scott", "tiger");

or

m_connection = DriverManager.getConnection("jdbc:oracle:oci7:@
(description=(address=(host=127.0.0.1)(protocol=tcp)(port=1521))
(connect_data=(sid=orcl)))","scott", "tiger");

5. Using classes111.zip is not an issue for jdk1.1.8 (however it is
an issue for jdk1.2.2).


Hope this helps, parsed

In article <Pine.OSF.4.21.000711...@student.uq.edu.au>,


BARRIE TAYLOR <s17...@student.uq.edu.au> wrote:
> I'm having very similar problems, using Oracle 7.3.4 on win98.

<snip>
> MAtt


Sent via Deja.com http://www.deja.com/
Before you buy.

0 new messages