DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2004

    Question 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 ("jdbcracleci8:@ExampleDb", "scott", "tiger");
    Statement stmt = conn.createStatement ();
    ResultSet rset = stmt.executeQuery ("select ENAME from EMP");
    while (rset.next ())
    System.out.println (rset.getString (1));

    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
    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.

  2. #2
    Join Date
    Nov 2004
    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

  3. #3
    Join Date
    Sep 2004
    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.

  4. #4
    Join Date
    Oct 2004
    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

  5. #5
    Join Date
    Sep 2004
    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
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.