当前位置:Gxlcms > 数据库问题 > DButil

DButil

时间:2021-07-01 10:21:17 帮助过:8人阅读

public class DBUtil {
    static {
        try {
            Class.forName("com.mysql.jdbc.Driver");

        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
           
e.printStackTrace();
        }
    }


    public static  Connection getConnection(){
        Connection conn=null;
        try {
            conn=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/apartmentsystemdb", "root", "admin");

        } catch (SQLException e) {
            // TODO Auto-generated catch block
           
e.printStackTrace();
        }
        return conn;
    }
    public static  void close(Connection conn){
        try {
            conn.close();

        } catch (SQLException e) {
            // TODO Auto-generated catch block
           
e.printStackTrace();
        }
    }
}

 

DButil

标签:static   trace   tco   exce   gen   dmi   emd   art   cat   

人气教程排行