我已尝试过网上几乎所有可用的方法来纠正错误,但它一直在弹出。
使用已修补的ojdbc6
来处理logging.properties
(oracle.jdbc.level=OFF
)等。没有任何效果。
我正在使用jdbc6
用于Android应用程序。大约一周前,应用程序运行正常(连接后的简单选择语句)。哈文没有改变任何东西,但突然停止了工作。
错误是
W/oracle.jdbc: Error while registering Oracle JDBC Diagnosability MBean.
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/lang/management/ManagementFactory;
at oracle.jdbc.driver.OracleDriver.registerMBeans(OracleDriver.java:322)
at oracle.jdbc.driver.OracleDriver$1.run(OracleDriver.java:201)
at java.security.AccessController.doPrivileged(AccessController.java:45)
at oracle.jdbc.driver.OracleDriver.<clinit>(OracleDriver.java:197)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:309)
at java.lang.Class.forName(Class.java:273)
at com.example.duke.jdbcoracle.MainActivity$ConnectToOracle.doInBackground(MainActivity.java:132)
at com.example.duke.jdbcoracle.MainActivity$ConnectToOracle.doInBackground(MainActivity.java:123)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.lang.management.ManagementFactory" on path: DexPathList[[zip file "/data/app/com.example.duke.jdbcoracle-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at oracle.jdbc.driver.OracleDriver.registerMBeans(OracleDriver.java:322)
at oracle.jdbc.driver.OracleDriver$1.run(OracleDriver.java:201)
at java.security.AccessController.doPrivileged(AccessController.java:45)
at oracle.jdbc.driver.OracleDriver.<clinit>(OracleDriver.java:197)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:309)
at java.lang.Class.forName(Class.java:273)
at com.example.duke.jdbcoracle.MainActivity$ConnectToOracle.doInBackground(MainActivity.java:132)
at com.example.duke.jdbcoracle.MainActivity$ConnectToOracle.doInBackground(MainActivity.java:123)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Suppressed: java.lang.ClassNotFoundException: java.lang.management.ManagementFactory
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 16 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
12-09 23:13:50.420 4414-4450/com.example.duke.jdbcoracle D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
我的代码是:
try {
//Load the Driver Class
//
Class.forName("oracle.jdbc.driver.OracleDriver");
//Create the Conneciton Object
//
Connection connection = DriverManager.getConnection(
"jdbc:oracle:thin:@192.168.0.103:1521:xe", "root", "starblazer"
);
//Create the Statement Object
Statement statement=connection.createStatement();
//Execute Query
ResultSet resultSet=statement.executeQuery("select * from users");
while(resultSet.next()){
result = result + resultSet.getString(1)+ " " + resultSet.getString(2) + "\n";
System.out.println(resultSet.getString(1)+ " " + resultSet.getString(2));
}
//Clsoe Connection
connection.close();
} catch (ClassNotFoundException e) {
//e.printStackTrace();
e.getMessage();
} catch (SQLException e) {
//e.printStackTrace();
e.getMessage();
}
答案 0 :(得分:0)
确定。经过尝试和过去3天的失败后,我找到了一个部分,我不需要在任何地方放置任何CLASSPATH等。我不知道解决方案是否正确,但它确实有效。
只需将ojdbc6.jre复制到
即可Linux
/usr/lib/jvm/YOUR_ORACLE/jre/lib/ext/
在Windows上
C:/program files/java/jre_yourversion/lib/ext/