Forum Discussion

ragirn's avatar
ragirn
New Contributor
15 years ago

oracle JDBC ERROR:java.lang.UnsatisfiedLink

Hi,

I am new to soap UI. I tried to connect to my organization database using JDBC request test step. That did not seem to work for me. I then tried to connect to database using groovy script, even that fails with UnsatisfiedLink error. I finally wrote a sample Java program to check if database connectivity works or not, it works fine.

I tried to Google the solution for this problem and I understood it has something to do with java.library.path variable, oracle bin path and dll files, but I can not think of a straight forward solution for this.

Note:
My organization security does not allow me to get the IP address and port of the oracle database server, they give me TNSNames_Entry and credentials.
The connection from toad with the TNS name, username and password worked fine for me.
Sample Java code provided below to worked fine and I can connect to database.
I have copied all the Jar files in %ORACLE_HOME%/jdbc/lib folder to %SOAPUI_HOME%/bin/ext folder.
The PATH environment variable is correctly set to %ORACLE_HOME%/BIN directory.

Any help / directions in this regard are highly appreciated. Feel free to ask for more information if you need


/* this java code snippet below works fine and I can execute DB queries */
static Connection conn;
...
try {
if(conn == null) {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:oci:@MYSID", "MYUSERNAME", "MYSECRETPASSWORD");
System.out.println("Handle Database here");

try {
Statement stmt = conn.createStatement();
try {
ResultSet rset = stmt.executeQuery("select sys_context('userenv','db_name') from dual"); // gives SID of Database
try {
while (rset.next())
System.out.println (rset.getString(1)); // Print col 1
} finally {
try { rset.close(); } catch (Exception ignore) {}
}
} finally {
try { stmt.close(); } catch (Exception ignore) {}
}
} finally {
try { conn.close(); } catch (Exception ignore) {}
}

}
} catch (Exception e1) {
System.out.println("caught below exception during DB Connection phase");
e1.printStackTrace();
}


Groovy script to connect to database. The below code fails with java.lang.UnsatisfiedLink exception

// Groovy script to connect to database.

import groovy.sql.Sql
import com.eviware.soapui.support.GroovyUtils.*

//try to create connection to database, if available.
//if not, log error
try {
//Class.forName("oracle.jdbc.driver.OracleDriver");
log.info "trying to connect to DB here";
log.info System.properties['java.library.path']
com.eviware.soapui.support.GroovyUtils.registerJdbcDriver("oracle.jdbc.driver.OracleDriver")
log.info "successfully registered Oracle driver";
Sql sql = Sql.newInstance("jdbc:oracle:oci:@MYSID","MYUSERNAME", "MYSECRETPASSSWORD", "oracle.jdbc.OracleDriver")
log.info "Successfully connected to DB";
} catch (Exception e) {
log.error "Could not establish connection to the database."
log.error e;
}


Below is the error I get when i try to execute the Groovy script to connect to oracle database.

ERROR:java.lang.UnsatisfiedLinkError: no ocijdbc10 in java.library.path
java.lang.UnsatisfiedLinkError: no ocijdbc10 in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at oracle.jdbc.driver.T2CConnection$1.run(T2CConnection.java:3134)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.jdbc.driver.T2CConnection.loadNativeLibrary(T2CConnection.java:3130)
at oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:220)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:413)
at oracle.jdbc.driver.T2CConnection.<init>(T2CConnection.java:131)
at oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtension.java:77)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:752)
at com.eviware.soapui.support.GroovyUtils$DriverShim.connect(GroovyUtils.java:132)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at groovy.sql.Sql.newInstance(Sql.java:248)
at groovy.sql.Sql.newInstance(Sql.java:269)
at groovy.sql.Sql$newInstance.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
at Script3.run(Script3.groovy:18)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:96)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:148)
at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:274)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

2 Replies

  • ragirn's avatar
    ragirn
    New Contributor
    Hi All,

    I got the solution for the problem I reported Above:)

    The problem can be solved by copying files ocijdbc10.dll and oci.dll to the %SOAPUI_HOME%/bin directory from %ORACLE_HOME%/BIN directory. Now I can connect to my remote oracle database with TNSNames_Entry.

    Both the Groovy script and JDBC test step work now.

    For JDBC teststep you can use below syntax:
    Driver: oracle.jdbc.driver.OracleDriver
    Connection String: jdbc:oracle:oci:USERNAME/MYSECRETPASSWORD@MYSID

    below is sample Groovy code to connect to database.


    //In a DB connect Script
    import groovy.sql.Sql
    import com.eviware.soapui.support.GroovyUtils.*

    //try to create connection to database
    //if not, log error
    //In order for this to work, you need to have jdbc driver jar file in $SOAPUI_HOME/bin/ext folder

    try {
    log.info "trying to connect to DB here";
    log.info System.properties['java.library.path']
    com.eviware.soapui.support.GroovyUtils.registerJdbcDriver("oracle.jdbc.driver.OracleDriver")
    Sql sql = Sql.newInstance("jdbc:oracle:oci:@MYSID","USERNAME", "MYSECRETPASSWORD", "oracle.jdbc.OracleDriver")
    sql.eachRow("select sys_context('userenv','db_name') from dual"){ row ->
    log.info row.getString(1) //prints the SID of database info window
    }
    log.info "Handled Database";
    } catch (Exception e) {
    log.error "Could not establish connection to the database."
    log.error e;
    }


    Any one facing similar issue please feel free to contact me / reply to this topic, I will be more than happy to help
  • I have followed instructions from this post but I am getting below error in a pop-up window. A screen shot is attached. There is no further detail I could find for this error. I am using the ojdbc6.jar, ocijdbc11.dll, and oci.dll files. Any help on the cause or how to troubleshoot will be appreciated.

    Can't get the Connection for specified properties; jave.sql.SQLException

    I am using SOAPUI Pro 4.5.1