package hunnu.sj.raise_money.DataBase;
import java.sql.Connection;
import java.sql.DriverManager;

public class DatabaseHelper {
    private static DatabaseHelper db = null;
    private static Connection conn = null;
    public static DatabaseHelper getDb(){
        if(db ==null){
            db = new DatabaseHelper();
        }
        return  db;
    }


    public static Connection getConnection(){//数据库连接池
        String username = "root";
        String password ="12345678";
        if(conn==null){
            try {
                Class.forName("com.mysql.jdbc.Driver");
                String url = "jdbc:mysql://39.105.116.16:3306/raise";
                conn = DriverManager.getConnection(url,username,password);
                return conn;
            }catch(Exception e){
                e.printStackTrace();
            }
            return null;
        }
        return conn;

    }

}
