1.链接MySQL
package Swing_1_Full_edition;
import java.sql.*;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;
public class MysqlUtil_Landing_interface {
//private double width ,height ;
private static Connection connection;
private static Statement statement;
private static ResultSet rs;
public static Properties ini = null;
public static Connection getConnection() throws Exception{
try {
//8.0以上用cj.
Class.forName("com.mysql.cj.jdbc.Driver");
//5.几
//Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost:3306/test";
String user="root";
String password="123456";
//String user = getIniKey ("UserID");
//String password1 = getIniKey ("Password");
connection=DriverManager.getConnection(url, user, password);
}catch (Exception e) {
System.out.println(e);
}finally {
return connection;
}
}
public static void close() throws SQLException{
//关闭是声明的反方