The error information is as follows:
E/AndroidRuntime: FATAL EXCEPTION: Thread-4
Process: com.example.NCEPU, PID: 19597
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/sql/SQLType;
at com.mysql.cj.jdbc.DatabaseMetaData.getInstance(DatabaseMetaData.java:746)
at com.mysql.cj.jdbc.ConnectionImpl.getMetaData(ConnectionImpl.java:1170)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:447)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
at java.sql.DriverManager.getConnection(DriverManager.java:580)
at java.sql.DriverManager.getConnection(DriverManager.java:218)
at com.example.NCEPU.Utils.MySQLUtil$1.run(MySQLUtil.java:20)
at java.lang.Thread.run(Thread.java:929)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.sql.SQLType" on path: DexPathList[[zip file "/data/app/com.example.NCEPU-ONfkLzQBKVHb0mVXKR3p5g==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.NCEPU-ONfkLzQBKVHb0mVXKR3p5g==/lib/arm64, /data/app/com.example.NCEPU-ONfkLzQBKVHb0mVXKR3p5g==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64, /hw_product/lib64, /system/product/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.mysql.cj.jdbc.DatabaseMetaData.getInstance(DatabaseMetaData.java:746)
at com.mysql.cj.jdbc.ConnectionImpl.getMetaData(ConnectionImpl.java:1170)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:447)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
at java.sql.DriverManager.getConnection(DriverManager.java:580)
at java.sql.DriverManager.getConnection(DriverManager.java:218)
at com.example.NCEPU.Utils.MySQLUtil$1.run(MySQLUtil.java:20)
at java.lang.Thread.run(Thread.java:929)
W/libEGL: EGLNativeWindowType 0x6f3882b950 disconnect failed
I/Process: Sending signal. PID: 19597 SIG: 9
Problem analysis: the jar package version of MySQL is too high. I used the latest version: mysql-connector-java-8.0.21.jar, loading driver:
Class.forName("com.mysql.cj.jdbc.Driver");
String url = "jdbc:mysql://yourip:port/sheetname?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC";
connection = DriverManager.getConnection(url, user, password);
Problem solved: jar version lower, here I used the official website to download mysql-connector-java-5.1.49.jar, note that after changing to a lower version to load the driver to become.
Class.forName("com.mysql.jdbc.Driver");
Read More:
- IDEA maven Config MYSQL Connection Error: Could not create connection to database server.
- [Solved] com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
- Remote connection to MySQL database error: is not allowed to connect to this MYSQL server solution
- [Solved] error {dataSource-1} init error java.sql.SQLException: com.mysql.cj.jdbc.Driver
- (Fixed) workbench MySQL Error Code: 2013. Lost connection to MySQL server during query
- [Solved] SQLSTATE[HY000] [2002] Connection refused to report an error when PHP connects to mysql in the docker container
- [Solved] MySQL connection error: communications link failure
- Docker: How to Solve MYSQL8 & Navicat remote connection error
- How to Solve can‘t connect to local mysql server through socket ‘/var/lib/mysql/mysql.sock‘
- [Solved] docker mysql SQLSTATE[HY000] [2002] Connection refused
- [Solved] Error Code: 2013. Lost connection to MySQL server during query
- [Solved] MYSQL Command Execute Error: Can ‘t connect to local MySQL server through socket ‘/tmp/mysql.sock ‘(2) “
- How to Solve MYSQL Error: Failed to start MySQL 8.0 database server
- [Solved] Druid connection pooling Error: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
- C# Connect MYSQL Error: MySql.Data.MySqlClient.MySqlException:“SSL Connection error.”
- MySql Install Error: Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘
- [Solved] init datasource error, url: jdbc:mysql://lcoalhost:3306/test com.mysql.cj.jdbc.exceptions.Com
- MySQL (version 8.0) connection error: 1251 [How to Solve]
- [Solved] There is a problem with mysql8.0 without password in Navicat connection
- [Solved] ERROR 2002 (HY000): Can’t connect to local MySQL server through socket’/var/lib/mysql/mysql.sock’ (2)