package utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DataBaseUtil {
    public static Connection getConnection() {
        Connection connection = null;
        try{
            Class.forName("com.mysql.jdbc.Driver");
            String url = "jdbc:mysql://localhost:3306/user";
            connection = DriverManager.getConnection(url, "root", "123");
            return connection;

        }catch(ClassNotFoundException nfe) {
            nfe.printStackTrace();
        }catch(SQLException sqle) {
            sqle.printStackTrace();
        }
        return connection;
    }

    public static void closeConnection(Connection connection) {
        if(connection != null) {
            try{
                connection.close();
            }catch(SQLException sqle) {
                sqle.printStackTrace();
            }
        }
    }
}
最近下载更多
2017143155  LV12 2023年6月30日
495997956  LV1 2023年6月15日
000666  LV10 2022年12月24日
与哲rhcy  LV6 2022年12月4日
wangchengwen  LV15 2021年6月3日
园林属于  LV7 2021年5月27日
live1018  LV12 2021年5月24日
luchen  LV6 2021年3月23日
myy1111  LV3 2021年2月23日
唯你不离不弃  LV5 2021年1月21日
最近浏览更多
yongle  LV1 2024年12月31日
ITkuangren  LV8 2023年10月7日
hongdongdong  LV14 2023年9月3日
nbzhou2013  LV14 2023年8月4日
2017143155  LV12 2023年6月30日
gyuguigiu  LV1 2023年6月27日
mrcao95  LV2 2023年6月26日
训码士 2023年6月17日
暂无贡献等级
495997956  LV1 2023年6月15日
Merdan_810 2023年6月9日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友