-
jdbc oracle connection ?
I Tried the following code to connect with
oracle using ocijdbc8 .It is given by oracle8i.
import java.sql.*;
class Employee
{
public static void main (String args [])
throws SQLException
{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn =
DriverManager.getConnection ("jdbc racle ci8:@ExampleDb", "scott", "tiger");
Statement stmt = conn.createStatement ();
ResultSet rset = stmt.executeQuery ("select ENAME from EMP");
while (rset.next ())
System.out.println (rset.getString (1));
rset.close();
stmt.close();
conn.close();
}
}
The program compiles well but gives the follwing
when i run it.
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:197)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:142)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
va:214)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:193)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
Can u suggest anything?
Thank you.
-
I havne't use oracle for ages. What seems to be wrong here is the connection string:
"jdbc;oracle;ci8:@ExampleDb". You should look into that.
eschew obfuscation
-
I'm using the database that gets automatically
created by oracle installation.
In the " Oracle JDBC Drivers release 8i README " i found
JDBC OCI8:
Connection conn =
DriverManager.getConnection ("jdbc:oracle:oci8:@<database>",
"scott", "tiger");
<database> is either an entry in tnsnames.ora or a SQL*net
name-value pair.
What i'm not confirm about is the database name.
It takes a bit of dba knowledge to create a database
in oracle. So i'm trying to use the existing db to test
oracle jdbc connection first.
Thank you for the above reply and for Any
further sugession.
-
Ok, your problem lies in your while loop.
You close your ResultSet, Connection and Statement in the while loop.
This should not be done here, since after closing a resultset, you can't iterate through it any further. Move the three close statements to after the wile loop, and all should work fine.
Oh, and on the exception stacktrace you send in: try using the thin driver in stead of the oci8 driver....
(just replace oci8 with thin in your connect string)
This should solve that problem
-
probably u havn't noticed the while loop minutely.
the two closing brackets r for closing main() and Employee class.
Sorry for the messy formatting of the post.
I replaced oci8 with thin. Again it compiled well
but there is new set of messages in the console.
Below is a Clip of them:
at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:381)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:149)
at oracle.jdbc.ttc7.TTC7Protocol.connect(TTC7Protocol.java:1085)
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:179)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:14
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:193)
What is the fix.
Thank u for any suggession.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks