运行java程序时出现以下错误:
Exception in thread "main" java.lang.UnsatisfiedLinkError: t2cPingDatabase
at oracle.jdbc.driver.T2CConnection.t2cPingDatabase(Native Method)
at oracle.jdbc.driver.T2CConnection.doPingDatabase(T2CConnection.java:503)
at oracle.jdbc.driver.PhysicalConnection.pingDatabase(PhysicalConnection.java:4886)
at oracle.jdbc.driver.PhysicalConnection.pingDatabase(PhysicalConnection.java:4899)
at oracle.jdbc.pool.OracleImplicitConnectionCache.testDatabaseConnection(OracleImplicitConnectionCache.java:2174)
at oracle.jdbc.pool.OracleImplicitConnectionCache.performPooledConnectionTask(OracleImplicitConnectionCache.java:1343)
at oracle.jdbc.pool.OracleImplicitConnectionCache.doForEveryCachedConnection(OracleImplicitConnectionCache.java:1208)
at oracle.jdbc.pool.OracleImplicitConnectionCache.refreshCacheConnections(OracleImplicitConnectionCache.java:1848)
at oracle.jdbc.pool.OracleConnectionCacheManager.refreshCache(OracleConnectionCacheManager.java:480)
at tkpjb7382521.refreshConnectionPool(tkpjb7382521.java:199)
at tkpjb7382521.test(tkpjb7382521.java:115)
at tkpjb7382521.run(tkpjb7382521.java:46)
at sqlj.qa.harness.AppJdbcHarness.RunTestCase(AppJdbcHarness.java:158)
at sqlj.qa.harness.AppJdbcHarness.main(AppJdbcHarness.java:79)
可能的原因是什么?
答案 0 :(得分:6)
当Java无法找到jar中引用的本机方法时,会抛出此错误。所以我的猜测是你使用本机(OCI)Oracle JDBC驱动程序,缺少或配置不正确的Oracle客户端配置,或者你的URL不正确,或者你只是缺少tnsnames.ora文件中的条目。
最简单的解决方案可能只是使用Oracle瘦JDBC驱动程序,而不需要安装Oracle TNS客户端。
答案 1 :(得分:3)
调用本机方法t2cPingDatabase,看起来JVM无法找到本机方法定义。可能是库路径问题。