工具类
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.swing.*;
import java.awt.image.BufferedImage;
import java.sql.*;
import java.util.*;
public class Util {
public static String driverName="com.mysql.cj.jdbc.Driver";
public static String dbURL="jdbc:mysql://localhost:3306/personal?serverTimezone=GMT";
public static String userName="root";
public static String userPwd="ALIM-MASTIK";
public static BufferedImage image;
public static Connection getConnections() throws ClassNotFoundException {
Class.forName(driverName);
try {
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/customer?serverTimezone=GMT", userName, userPwd);
return connection;
}catch (SQLException e) {
throw new RuntimeException("连接错误!!!!");
}
}
public static Connection getConnection() throws ClassNotFoundException {
Class.forName(driverName);
try {
Connection con= DriverManager.getConnection(dbURL,userName,userPwd);
return con;
} catch (SQLException e) {
throw new RuntimeException("连接错误!!!!");
}
}
public static void close(Connection con, Statement statement) {
if (statement!=null) {
try {
statement.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
if (con!=null) {
try {
con.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
public static void close(ResultSet resultSet,Connection connection, Statement statement){
if (resultSet!=null) {
try {
resultSet.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
if (connection!=null) {
try {
connection.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
public static void close(ResultSet resultSet,Connection connection, PreparedStatement atement){
if (resultSet!=null) {
try {
resultSet.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
if (connection!=null) {
try {
connection.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
public static void JudgeCreateTable(String TableName){
Connection con=null;
PreparedStatement preparedStatement=null;
ResultSet resultSet=null;
try {
con= Util.getConnections(