wangchengyong
2012-12-21 16:34 阅读 365
已采纳

java web jdbc oci 方式连接oracle报错UnsatisfiedLinkError

环境为AIX Version 5.3!
sqlplus sqlldr 可用,
java web jdbc oci 方式连接数据库不成功
Connection conn = null;

Statement stmt = null;

ResultSet rs = null;

try {

Class.forName("oracle.jdbc.OracleDriver");

conn = DriverManager.getConnection("jdbc:oracle:oci:@bbs", "user", "password");

stmt = conn.createStatement();

rs = stmt.executeQuery("select name from abc");

while (rs.next()) {  
    String s = rs.getString(1);  
    System.out.println(s);  
}  

} catch (Exception e) {

e.printStackTrace();

}

System.out.println(System.getProperties().get("java.library.path"));输出:/oracle11/app/oracle/11.2.0/lib

windows上测试成功:
-Djava.library.path=E:\oracle\product\10.2.0\client_1\BIN

报错信息
INFO: Server startup in 1286 ms
Exception in thread "Timer-0" java.lang.UnsatisfiedLinkError: ocijdbc11 (A file or directory in the path name does not exist.)
at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:986)
at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:950)
at java.lang.System.loadLibrary(System.java:453)
at oracle.jdbc.driver.T2CConnection$1.run(T2CConnection.java:3516)
at java.security.AccessController.doPrivileged(AccessController.java:197)
at oracle.jdbc.driver.T2CConnection.loadNativeLibrary(T2CConnection.java:3512)
at oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:266)
at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:536)
at oracle.jdbc.driver.T2CConnection.(T2CConnection.java:162)
at oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtension.java:53)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
at java.sql.DriverManager.getConnection(DriverManager.java:572)
at java.sql.DriverManager.getConnection(DriverManager.java:196)
at com.gmail.wangchengyong2009.db.OracleETL.getQueryColumnName(OracleETL.java:374)

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    blogzhoubo blogzhoubo 2012-12-22 07:36

    配置一下环境变量:
    Add [ORACLE_HOME]/jdbc/lib/ojdbc5.jar to your CLASSPATH if you use JDK 1.5 or [ORACLE_HOME]/jdbc/lib/ojdbc6.jar if you use JDK 1.6

    • Add [ORACLE_HOME]/jlib/orai18n.jar to your CLASSPATH if needed.

    • Add [ORACLE_HOME]/jdbc/lib to your LIBPATH and LD_LIBRARY_PATH if you use the JDBC OCI driver.

    点赞 评论 复制链接分享

相关推荐