Android Oracle 数据库 JDBC6

Android Oracle Database JDBC6(Android Oracle 数据库 JDBC6)

本文介绍了Android Oracle 数据库 JDBC6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想创建一个到我的 Oracle 数据库的连接.我以前使用过 ojdbc14.jar,一切正常,但连接应该是安全的,我想加密文件.所以我决定现在使用 ojdbc5.jar.jar 是我的libs"文件夹

Hi i want to create a connection to my Oracle database. i previously used ojdbc14.jar and everything was working fine, but the connection should be secure and i want to encrypt the files. so i decided to use ojdbc5.jar now. the jar is im my "libs" folder

从 jdbc14 更改为 jdbc6 的原因我想使用属性在我的数据库和我的设备之间进行安全的数据交换

Reasons for changing from jdbc14 to jdbc6 i want to use Properties for a secure data exchange between my DB and my devices

之前我也尝试过 jdbc5,但这样我只得到了 java Heap Size 错误.

earlier i also tried jdbc5 but with this i only got a java Heap Size error.

public class MainActivity extends Activity
{

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        jdbccoonect connect = new jdbccoonect();
        connect.execute();


    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu)
    {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

    private class jdbccoonect extends AsyncTask<Void, Integer, Boolean>
    {

        @Override
        protected Boolean doInBackground(Void... params)
        {
            // TODO Auto-generated method stub
            String username = "scott";
            String password = "tiger";
            try
            {
                Log.d("HI","HI");
                Class.forName("oracle.jdbc.OracleDriver");
                            //Class.forName("oracle.jdbc.driver.OracleDriver");



                /*Connection conn = DriverManager
                        .getConnection("jdbc:oracle:thin://@10.10.0.9:1521/service",
                                        username, password);*/

                Log.d("HI","HI");
            }
            catch (ClassNotFoundException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

    }

}

错误:

01-05 22:27:56.814: D/HI(1610): HI
01-05 22:27:57.005: E/dalvikvm(1610): Could not find class 'javax.management.MBeanServer', referenced from method oracle.jdbc.driver.OracleDriver.registerMBeans
01-05 22:27:57.005: W/dalvikvm(1610): VFY: unable to resolve check-cast 716 (Ljavax/management/MBeanServer;) in Loracle/jdbc/driver/OracleDriver;
01-05 22:27:57.005: D/dalvikvm(1610): VFY: replacing opcode 0x1f at 0x002d
01-05 22:27:57.005: I/dalvikvm(1610): Could not find method java.lang.management.ManagementFactory.getPlatformMBeanServer, referenced from method oracle.jdbc.driver.OracleDriver.registerMBeans
01-05 22:27:57.005: W/dalvikvm(1610): VFY: unable to resolve static method 3734: Ljava/lang/management/ManagementFactory;.getPlatformMBeanServer ()Ljavax/management/MBeanServer;
01-05 22:27:57.005: D/dalvikvm(1610): VFY: replacing opcode 0x71 at 0x0080
01-05 22:27:57.015: I/dalvikvm(1610): Could not find method java.lang.management.ManagementFactory.getPlatformMBeanServer, referenced from method oracle.jdbc.driver.OracleDriver.registerMBeans
01-05 22:27:57.015: W/dalvikvm(1610): VFY: unable to resolve static method 3734: Ljava/lang/management/ManagementFactory;.getPlatformMBeanServer ()Ljavax/management/MBeanServer;
01-05 22:27:57.015: D/dalvikvm(1610): VFY: replacing opcode 0x71 at 0x0094
01-05 22:27:57.015: I/dalvikvm(1610): Could not find method java.lang.management.ManagementFactory.getPlatformMBeanServer, referenced from method oracle.jdbc.driver.OracleDriver.registerMBeans
01-05 22:27:57.015: W/dalvikvm(1610): VFY: unable to resolve static method 3734: Ljava/lang/management/ManagementFactory;.getPlatformMBeanServer ()Ljavax/management/MBeanServer;
01-05 22:27:57.015: D/dalvikvm(1610): VFY: replacing opcode 0x71 at 0x00a8
01-05 22:27:57.015: I/dalvikvm(1610): Could not find method java.lang.management.ManagementFactory.getPlatformMBeanServer, referenced from method oracle.jdbc.driver.OracleDriver.registerMBeans
01-05 22:27:57.015: W/dalvikvm(1610): VFY: unable to resolve static method 3734: Ljava/lang/management/ManagementFactory;.getPlatformMBeanServer ()Ljavax/management/MBeanServer;
01-05 22:27:57.015: D/dalvikvm(1610): VFY: replacing opcode 0x71 at 0x00bc
01-05 22:27:57.015: I/dalvikvm(1610): Could not find method java.lang.management.ManagementFactory.getPlatformMBeanServer, referenced from method oracle.jdbc.driver.OracleDriver.registerMBeans
01-05 22:27:57.015: W/dalvikvm(1610): VFY: unable to resolve static method 3734: Ljava/lang/management/ManagementFactory;.getPlatformMBeanServer ()Ljavax/management/MBeanServer;
01-05 22:27:57.015: D/dalvikvm(1610): VFY: replacing opcode 0x71 at 0x00d1
01-05 22:27:57.025: W/dalvikvm(1610): VFY: unable to resolve exception class 712 (Ljavax/management/JMException;)
01-05 22:27:57.025: W/dalvikvm(1610): VFY: unable to resolve exception class 712 (Ljavax/management/JMException;)
01-05 22:27:57.025: W/dalvikvm(1610): VFY: unable to resolve exception class 712 (Ljavax/management/JMException;)
01-05 22:27:57.025: W/dalvikvm(1610): VFY: unable to find exception handler at addr 0xfa
01-05 22:27:57.025: W/dalvikvm(1610): VFY: rejected Loracle/jdbc/driver/OracleDriver;.registerMBeans ()V
01-05 22:27:57.025: W/dalvikvm(1610): VFY: rejecting opcode 0x0d at 0x00fa
01-05 22:27:57.025: W/dalvikvm(1610): VFY: rejected Loracle/jdbc/driver/OracleDriver;.registerMBeans ()V
01-05 22:27:57.025: W/dalvikvm(1610): Verifier rejected class Loracle/jdbc/driver/OracleDriver;
01-05 22:27:57.035: W/System.err(1610): java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
01-05 22:27:57.055: W/System.err(1610): at java.lang.Class.classForName(Native Method)
01-05 22:27:57.055: W/System.err(1610): at java.lang.Class.forName(Class.java:234)
01-05 22:27:57.055: W/System.err(1610): at java.lang.Class.forName(Class.java:181)
01-05 22:27:57.055: W/System.err(1610): at at.security.jdbcsecuritydemo.MainActivity$jdbccoonect.doInBackground(MainActivity.java:51)
01-05 22:27:57.055: W/System.err(1610): at at.security.jdbcsecuritydemo.MainActivity$jdbccoonect.doInBackground(MainActivity.java:1)
01-05 22:27:57.065: W/System.err(1610): at android.os.AsyncTask$2.call(AsyncTask.java:185)
01-05 22:27:57.065: W/System.err(1610): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
01-05 22:27:57.065: W/System.err(1610): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
01-05 22:27:57.065: W/System.err(1610): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
01-05 22:27:57.065: W/System.err(1610): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
01-05 22:27:57.075: W/System.err(1610): at java.lang.Thread.run(Thread.java:1019)
01-05 22:27:57.085: W/System.err(1610): Caused by: java.lang.VerifyError: oracle.jdbc.driver.OracleDriver
01-05 22:27:57.085: W/System.err(1610): ... 11 more
01-05 22:27:57.205: D/gralloc_goldfish(1610): Emulator without GPU emulation detected.

推荐答案

Android 的 Java 与 Oracle 的 Java 不同.主要区别之一是与 Java 标准版 (SE) 不同的类库.

Android's Java is different from Oracle's Java. One of the main differences is the class library that differs from the Java Standard Edition (SE).

在您的情况下,这意味着 ojdbc6.jar 不会在 Android 的 Java 环境中运行,因为某些 Java SE 类是必需的,但在 Android 上不可用.错误消息提到 javax.management.MBeanServer.但我很确定这不是唯一的.

In your case that means that ojdbc6.jar won't run in Android's Java environment because certain Java SE classes are required but not available on Android. The error message mentions javax.management.MBeanServer. But I'm pretty sure that's not the only one.

我认为你不能让 ojdbc6.jar 在 Android 上运行.ojdbc14.jar 的工作已经令人惊讶了.因此,请继续使用它,或者重新设计您的应用以通过中间服务器运行.

I don't think you can make ojdbc6.jar work on Android. It's already surprising that ojdbc14.jar works. So stay with it, or redesign your app to go via an intermediary server.

这篇关于Android Oracle 数据库 JDBC6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Android Oracle 数据库 JDBC6

基础教程推荐