package dao;
/**
* @author 作者: guya
* description:
*/
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import util.JdbcUtil;
public class DbUtil {
public static Connection getConnection() {
Connection conn=null;
try {
Class.forName("com.mysql.cj.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/db_exam?useSSL=false&serverTimezone=UTC",
"root", "123456");
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
return conn;
}
public static void close(Connection connn,Statement st){
try {
st.close();
connn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public static void close(Connection connn,PreparedStatement ps){
try {
ps.close();
connn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public static void close(Connection connn,PreparedStatement ps, ResultSet rs){
try {
rs.close();
ps.close();
connn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public static void close(Connection connn,Statement st, ResultSet rs){
try {
rs.close();
st.close();
connn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
System.out.println(getConnection());
}
}
最近下载更多
liuliuyl LV3
2023年6月17日
小顾顾顾顾顾 LV4
2023年6月7日
ZDM133 LV2
2023年5月22日
人生三重奏 LV1
2022年12月21日
无名氏111 LV33
2022年12月16日
1379585889 LV11
2022年12月14日
bigstone1 LV1
2022年11月9日
微信网友_6208827097387008 LV1
2022年11月7日
sdkjfhg LV1
2022年3月6日
guanxiaopeng LV1
2021年12月21日

最近浏览