拒绝对先前失败的类java.lang.Class <com.mysql.cj.mysqltype>进行重新初始化

时间:2019-04-03 22:06:30

标签: java android mysql noclassdeffounderror mysql-error-1064

我正在构建一个移动应用程序,并试图将其连接到我在本地主机上托管的MySql数据库。基本上,用户填写一些信息,然后提交票证。该票证应该插入到数据库中,但是却出现了错误。该应用程序将继续运行(因此不会使该应用程序崩溃),但该查询永远不会运行。

我尝试清理并重建Android Studio项目。我也尝试过使缓存无效并重新启动。我尝试将一些代码添加到我的app.build gradle文件中,但它也不起作用。

使用的代码:

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            // Skip multidex because it follows a different versioning pattern.
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.3.0'
            }
        }
    }
}

这是我的错误消息:

Rejecting re-init on previously-failed class java.lang.Class<com.mysql.cj.MysqlType>: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/sql/SQLType;
        at com.mysql.cj.jdbc.DatabaseMetaData com.mysql.cj.jdbc.DatabaseMetaData.getInstance(com.mysql.cj.jdbc.JdbcConnection, java.lang.String, boolean, com.mysql.cj.jdbc.result.ResultSetFactory) (DatabaseMetaData.java:729)
        at java.sql.DatabaseMetaData com.mysql.cj.jdbc.ConnectionImpl.getMetaData(boolean, boolean) (ConnectionImpl.java:1175)
        at void com.mysql.cj.jdbc.ConnectionImpl.<init>(com.mysql.cj.conf.HostInfo) (ConnectionImpl.java:447)
        at com.mysql.cj.jdbc.JdbcConnection com.mysql.cj.jdbc.ConnectionImpl.getInstance(com.mysql.cj.conf.HostInfo) (ConnectionImpl.java:240)
        at java.sql.Connection com.mysql.cj.jdbc.NonRegisteringDriver.connect(java.lang.String, java.util.Properties) (NonRegisteringDriver.java:207)
        at java.sql.Connection java.sql.DriverManager.getConnection(java.lang.String, java.util.Properties, java.lang.ClassLoader) (DriverManager.java:569)
        at java.sql.Connection java.sql.DriverManager.getConnection(java.lang.String, java.lang.String, java.lang.String) (DriverManager.java:219)
        at void com.example.vanda.agrivolution.MySqlUsage.submitTicket(java.lang.String[]) (MySqlUsage.java:17)
        at void com.example.vanda.agrivolution.SubmitIssue.addToList() (SubmitIssue.java:130)
        at void com.example.vanda.agrivolution.SubmitIssue.access$100(com.example.vanda.agrivolution.SubmitIssue) (SubmitIssue.java:19)
        at void com.example.vanda.agrivolution.SubmitIssue$2.onClick(android.view.View) (SubmitIssue.java:73)
        at boolean android.view.View.performClick() (View.java:6597)
        at boolean android.view.View.performClickInternal() (View.java:6574)
        at boolean android.view.View.access$3100(android.view.View) (View.java:778)
        at void android.view.View$PerformClick.run() (View.java:25885)
        at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:873)
        at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:99)
        at void android.os.Looper.loop() (Looper.java:193)
        at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6669)
        at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
        at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:493)
        at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:858)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "java.sql.SQLType" on path: DexPathList[[zip file "/data/app/com.example.vanda.agrivolution-Rtbi1zkpK7mJXfDWkDIjHg==/base.apk", zip file "/data/app/com.example.vanda.agrivolution-Rtbi1zkpK7mJXfDWkDIjHg==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.vanda.agrivolution-Rtbi1zkpK7mJXfDWkDIjHg==/split_lib_resources_apk.apk", zip file "/data/app/com.example.vanda.agrivolution-Rtbi1zkpK7mJXfDWkDIjHg==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.vanda.agrivolution-Rtbi1zkpK7mJXfDWkDIjHg==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.vanda.agrivolution-Rtbi1zkpK7mJXfDWkDIjHg==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.vanda.agrivolution-Rtbi1zkpK7mJXfDWkDIjHg==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.vanda.agrivolution-Rtbi1zkpK7mJXfDWkDIjHg==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.vanda.agrivolution-Rtbi1zkpK7mJXfDWkDIjHg==/split_lib_slice_5_apk
        at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:134)
        at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
        at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
        at com.mysql.cj.jdbc.DatabaseMetaData com.mysql.cj.jdbc.DatabaseMetaData.getInstance(com.mysql.cj.jdbc.JdbcConnection, java.lang.String, boolean, com.mysql.cj.jdbc.result.ResultSetFactory) (DatabaseMetaData.java:729)
        at java.sql.DatabaseMetaData com.mysql.cj.jdbc.ConnectionImpl.getMetaData(boolean, boolean) (ConnectionImpl.java:1175)
        at void com.mysql.cj.jdbc.ConnectionImpl.<init>(com.mysql.cj.conf.HostInfo) (ConnectionImpl.java:447)
        at com.mysql.cj.jdbc.JdbcConnection com.mysql.cj.jdbc.ConnectionImpl.getInstance(com.mysql.cj.conf.HostInfo) (ConnectionImpl.java:240)
        at java.sql.Connection com.mysql.cj.jdbc.NonRegisteringDriver.connect(java.lang.String, java.util.Properties) (NonRegisteringDriver.java:207)
        at java.sql.Connection java.sql.DriverManager.getConnection(java.lang.String, java.util.Properties, java.lang.ClassLoader) (DriverManager.java:569)
        at java.sql.Connection java.sql.DriverManager.getConnection(java.lang.String, java.lang.String, java.lang.String) (DriverManager.java:219)
        at void com.example.vanda.agrivolution.MySqlUsage.submitTicket(java.lang.String[]) (MySqlUsage.java:17)
        at void com.example.vanda.agrivolution.SubmitIssue.addToList() (SubmitIssue.java:130)
        at void com.example.vanda.agrivolution.SubmitIssue.access$100(com.example.vanda.agrivolution.SubmitIssue) (SubmitIssue.java:19)
        at void com.example.vanda.agrivolution.SubmitIssue$2.onClick(android.view.View) (SubmitIssue.java:73)
        at boolean android.view.View.performClick() (View.java:6597)
        at boolean android.view.View.performClickInternal() (View.java:6574)
        at boolean android.view.View.access$3100(android.view.View) (View.java:778)
        at void android.view.View$PerformClick.run() (View.java:25885)
        at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:873)
        at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:99)
        at void android.os.Looper.loop() (Looper.java:193)
        at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6669)
        at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
        at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:493)
        at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:858)

我还已将mysql驱动程序添加到android studio中的项目结构中。您可以在下图的窗口底部看到它。
ProjectStructure

我的预期结果是它将被加载到数据库中,如果我运行全选语句,我将能够在数据库中看到它,但是我所拥有的只是一个空数据库。

0 个答案:

没有答案