current position:Home>Java database: error caused by: Java lang.ClassNotFoundException: Didn't find class 'java. sql. Sqltype 'problem, how to solve it?

Java database: error caused by: Java lang.ClassNotFoundException: Didn't find class 'java. sql. Sqltype 'problem, how to solve it?

2022-02-02 19:26:23 CSDN Q & A

The phenomenon and background of the problem

sdk edition :Android 12
Use mysql-connector-java-8016.jar
The server mysql edition mysql8012

public class DbOpenHelper {    private static final String driver = "com.mysql.cj.jdbc.Driver";    private static final String url = "jdbc:mysql://xxx.xxx.xxx.xxx:3306/wsgd?useSSL=false&useUnicode=true&characterEncoding=utf8&allowPublicKeyRetrieval=true&serverTimezone=UTC";    private static final String user = "root";    private static final String pwd = "2#w1*s>2g]d0/";    public static Connection conn;    public static Statement sql = null;    public static ResultSet rs = null;    /** * mysql Connect  * * @return */    public static Connection getConnection() {        if (conn == null) {            try {                // obtain  mysql  drive                 Class.forName(driver);                // Get the connection                 conn = (Connection) DriverManager.getConnection(url, user, pwd);            } catch (ClassNotFoundException e) {                e.printStackTrace();            } catch (SQLException e) {                e.printStackTrace();            }        }        return conn;    }}
Operation results and error reporting contents

Report errors :java.lang.NoClassDefFoundError: Failed resolution of: Ljava/sql/SQLType;
Report errors :Caused by: java.lang.ClassNotFoundException: Didn't find class "java.sql.SQLType" on path: DexPathList[[dex file "/data/data/com.example.wsgd/code_cache/.overlay/base.apk/classes4.dex", dex file "/data/data/com.example.wsgd/code_cache/.overlay/base.apk/classes3.dex", zip file "/data/app/JKmtUgUAorwJxqxzPI9Yjg==/com.example.wsgd-9hZSrcfb2A5vmuM8li-9UQ==/base.apk"],nativeLibraryDirectories=[/data/app/JKmtUgUAorwJxqxzPI9Yjg==/com.example.wsgd-9hZSrcfb2A5vmuM8li-9UQ==/lib/x86_64, /system/lib64, /system_ext/lib64]]

My solution ideas and tried methods

I feel like sql Connection string problem But after reading a lot of solutions, it can't be solved




Refer to the answer 1:

JDK What's the version of , Didn't write SQL Statement configuration ? See if there are any different .

jdbc:mysql://localhost:3306/citymanager?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true



Refer to the answer 2:



Refer to the answer 3:

The version of the driver package is higher , A little lower .
Are you sure? mysql The database version is 8 Well .




Refer to the answer 4:



Refer to the answer 5:

Change some msql Test drive package




Refer to the answer 6:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202021926212905.html

Random recommended