我已经看过这个话题:Unknown initial character set index '255' received from server
但我没有 pom.xml,我使用 .jar 作为依赖项。我已经在我的项目中设置了最近和/或当前的 MySQL 连接器,但异常仍然存在。
我正在使用 MySQL 8.0
这在我将 MySQL 5 更新到 8 后开始发生
这是我的连接类:
package br.com.sat.util;
import java.sql.Connection;
import java.sql.*;
public class ConnectionFactory {
public static Connection getConnection() throws Exception {
try {
Class.forName("com.mysql.jdbc.Driver");
return DriverManager.getConnection("jdbc:mysql://localhost:3306/test_wim",
"root", "*******");
} catch (Exception e) {
throw new Exception(e.getMessage());
}
}
public static void closeConnection(Connection conn, PreparedStatement ps, ResultSet rs) throws Exception {
close(conn, ps, rs);
}
public static void closeConnection(Connection conn, PreparedStatement ps) throws Exception {
close(conn, ps, null);
}
private static void close(Connection conn, PreparedStatement ps, ResultSet rs) throws Exception {
try {
if (rs != null)
rs.close();
if (ps != null)
ps.close();
if (conn != null)
conn.close();
} catch (Exception e) {
throw new Exception(e.getMessage());
}
}
}
阿波罗的战车
萧十郎
跃然一笑
哈士奇WWW
随时随地看视频慕课网APP
相关分类