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</ Font> I originally used the latest version: mysql-connector-java-8.0.21.jar
Class.forName("com.mysql.cj.jdbc.Driver");
String url = "jdbc:mysql://your ip:port/dbname?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC";
connection = DriverManager.getConnection(url, user, password);
Problem solving: the jar version is a little lower. Here I use mysql-connector-java-5.1.49.jar downloaded from the official website. Note that after changing to the lower version, the loading driver should change to:
Class.forName("com.mysql.jdbc.Driver");
Similar Posts:
- mysql connection reports java.math.BigInteger cannot be cast to java.lang.Long exception
- Java.math.BigInteger cannot be cast to java.lang.Long [How to Solve]
- [Solved] MySQL Error: com.mysql.cj.jdbc.util.TimeUtil.loadTimeZoneMappings(TimeUtil.java:163)
- com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
- The jdbc driver imported from idea into MySQL appears “Java. Lang. classnotfoundexception: com. Mysql. CJ. JDBC. Driver”
- Thread.currentThread().getContextClassLoader()Class.getClassLoader()
- Project startup error: communications link failure
- [Solved] Hive Error: java.sql.SQLException: No suitable driver found for jdbc:hive://localhost:10000/default
- SSM Project Error: java.sql.SQLException: Access denied for user ‘????…§’@’localhost’ (…
- [Solved] Mybatis Codes Error: java.lang.ClassNotFoundException: Cannot find class: com.mysql.jdbc.Driver