我的应用程序在尝试连接Oracle数据库时崩溃了

时间:2018-04-02 16:31:29

标签: android database oracle

我是Android Studio的新手,我正在尝试创建一个必须从数据库中读取信息的应用程序。我已经创建了一个数据库,现在我正在尝试将它连接到我的应用程序。但它崩溃了。如果有人能帮助我,我将非常感激。谢谢!使用Java,eclipse中的连接没有问题。

这是我的代码:

package com.example.sergey.autohuttererapp;

import android.inputmethodservice.KeyboardView;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.sql.*;

public class MainActivity extends AppCompatActivity {
  private final static String url = "myurl;
  private final static String user = "myuser";
  private final static String pass = "mypass";
  private TextView name, vorname, email, telefon, vertragnmr, datum, person, status;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    name = (TextView) findViewById(R.id.idName);
    vorname = (TextView) findViewById(R.id.idVorname);
    email = (TextView) findViewById(R.id.idEmail);
    telefon = (TextView) findViewById(R.id.idTelefon);
    vertragnmr = (TextView) findViewById(R.id.idVertragnmr);
    datum = (TextView) findViewById(R.id.idDatum);
    person = (TextView) findViewById(R.id.idPerson);
    status = (TextView) findViewById(R.id.idStatus);
    Button buttonex = (Button) findViewById(R.id.idExec);



    buttonex.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new myTask().execute();
        }
    });
}
private class myTask extends AsyncTask<Void, Void, Void>{
    private String sname = "";
    private String svorname = "";
    private String semail = "";
    private String sdatum = "";
    private String  sperson = "";
    private String sstatus = "";
    private int itelefon = 0;
    private int ivertragnmr = 0;


    @Override
    protected Void doInBackground(Void... arg) {

        try {
            DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
            Connection con;
            con = DriverManager.getConnection(url, user, pass);
            Statement stmt;
            stmt = con.createStatement();
            String sqlstmt = "Select * from KUNDEN where ID = 4";

            final ResultSet rs = stmt.executeQuery(sqlstmt);
            rs.next();
            sname = rs.getString("NAME");
            svorname = rs.getString("VORNAME");
            semail = rs.getString("EMAIL");
            sperson = rs.getString("PERSON");
            sstatus = rs.getString("STATUS");
            itelefon = rs.getInt("TELEFON");
            ivertragnmr = rs.getInt("VRTNUMMER");


        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    protected void onPostExecute (Void result){

        name.setText(sname);
        vorname.setText(svorname);
        email.setText(semail);
        telefon.setText(itelefon);
        vertragnmr.setText(ivertragnmr);
        person.setText(sperson);
        status.setText(sstatus);
        super.onPostExecute(result);
    }
}


}

这是日志:

java.lang.RuntimeException: An error occurred while executing doInBackground()
  at android.os.AsyncTask$3.done(AsyncTask.java:318)
  at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
  at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
  at java.util.concurrent.FutureTask.run(FutureTask.java:242)
  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
  at java.lang.Thread.run(Thread.java:762)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Loracle/jdbc/driver/BlockSource$ThreadedCachingBlockSource$BlockReleaserListener;
  at oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource.<clinit>(BlockSource.java:402)
  at oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource.createBlockSource(BlockSource.java:429)
  at oracle.jdbc.driver.BlockSource.createBlockSource(BlockSource.java:80)
  at oracle.jdbc.driver.BlockSource.createBlockSource(BlockSource.java:70)
  at oracle.jdbc.driver.PhysicalConnection.setBlockSource(PhysicalConnection.java:656)
  at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:699)
  at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:385)
  at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:30)
  at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:564)
  at java.sql.DriverManager.getConnection(DriverManager.java:569)
  at java.sql.DriverManager.getConnection(DriverManager.java:219)
  at com.example.sergey.autohuttererapp.MainActivity$myTask.doInBackground(MainActivity.java:59)
  at com.example.sergey.autohuttererapp.MainActivity$myTask.doInBackground(MainActivity.java:42)
  at android.os.AsyncTask$2.call(AsyncTask.java:304)
  at java.util.concurrent.FutureTask.run(FutureTask.java:237)
  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) 
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
  at java.lang.Thread.run(Thread.java:762) 
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource$BlockReleaserListener
  at java.lang.VMClassLoader.findLoadedClass(Native Method)
  at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:742)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:362)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
  at oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource.<clinit>(BlockSource.java:402) 
  at oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource.createBlockSource(BlockSource.java:429) 
  at oracle.jdbc.driver.BlockSource.createBlockSource(BlockSource.java:80) 
  at oracle.jdbc.driver.BlockSource.createBlockSource(BlockSource.java:70) 
  at oracle.jdbc.driver.PhysicalConnection.setBlockSource(PhysicalConnection.java:656) 
  at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:699) 
  at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:385) 
  at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:30) 
  at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:564) 
  at java.sql.DriverManager.getConnection(DriverManager.java:569) 
  at java.sql.DriverManager.getConnection(DriverManager.java:219) 
  at com.example.sergey.autohuttererapp.MainActivity$myTask.doInBackground(MainActivity.java:59) 
  at com.example.sergey.autohuttererapp.MainActivity$myTask.doInBackground(MainActivity.java:42) 
  at android.os.AsyncTask$2.call(AsyncTask.java:304) 
  at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) 
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
  at java.lang.Thread.run(Thread.java:762) 
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/management/NotificationListener;
  at oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource.<clinit>(BlockSource.java:402) 
  at oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource.createBlockSource(BlockSource.java:429) 
  at oracle.jdbc.driver.BlockSource.createBlockSource(BlockSource.java:80) 
  at oracle.jdbc.driver.BlockSource.createBlockSource(BlockSource.java:70) 
  at oracle.jdbc.driver.PhysicalConnection.setBlockSource(PhysicalConnection.java:656) 
  at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:699) 
  at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:385) 
  at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:30) 
  at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:564) 
  at java.sql.DriverManager.getConnection(DriverManager.java:569) 
  at java.sql.DriverManager.getConnection(DriverManager.java:219) 
  at com.example.sergey.autohuttererapp.MainActivity$myTask.doInBackground(MainActivity.java:59) 
  at com.example.sergey.autohuttererapp.MainActivity$myTask.doInBackground(MainActivity.java:42) 
  at android.os.AsyncTask$2.call(AsyncTask.java:304) 
  at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) 
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
  at java.lang.Thread.run(Thread.java:762) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.management.NotificationListener" on path: DexPathList[[zip file "/data/app/com.example.sergey.autohuttererapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.sergey.autohuttererapp-1/lib/arm64, /system/lib64, /vendor/lib64]]
  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
  at oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource.<clinit>(BlockSource.java:402) 
  at oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource.createBlockSource(BlockSource.java:429) 
  at oracle.jdbc.driver.BlockSource.createBlockSource(BlockSource.java:80) 
  at oracle.jdbc.driver.BlockSource.createBlockSource(BlockSource.java:70) 
  at oracle.jdbc.driver.PhysicalConnection.setBlockSource(PhysicalConnection.java:656) 
  at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:699) 
  at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:385) 
  at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:30) 
  at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:564) 
  at java.sql.DriverManager.getConnection(DriverManager.java:569) 
  at java.sql.DriverManager.getConnection(DriverManager.java:219) 
  at com.example.sergey.autohuttererapp.MainActivity$myTask.doInBackground(MainActivity.java:59) 
  at com.example.sergey.autohuttererapp.MainActivity$myTask.doInBackground(MainActivity.java:42) 
  at android.os.AsyncTask$2.call(AsyncTask.java:304) 
  at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) 
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
  at java.lang.Thread.run(Thread.java:762) 

0 个答案:

没有答案