6 Star 1 Fork 1

你先别急队/电子公文传输系统

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
SQLConnection.java 1.17 KB
一键复制 编辑 原始数据 按行查看 历史
蔡笃俊 提交于 2022-11-24 09:01 +08:00 . 连接本地数据库
package helper;
import java.sql.*;
public class SQLConnection {
static String dbDriver="com.mysql.jdbc.Driver";
static{
try{
}catch(Exception ex){
System.out.print("---------------------om.microsoft.sqlserver.jdbc.SQLServerDri");
ex.printStackTrace();
}
}
public static Connection getConn(){
try{
Class.forName(dbDriver).newInstance();
Connection conn=DriverManager.getConnection("jdbc:mysql://127.0.0.1/gwlzxt?user=root&password=123456&useUnicode=true&characterEncoding=GBK");
return conn;
}catch(Exception ex){
ex.printStackTrace();
return null;
}
}
public static void close(Connection conn,Statement st,ResultSet rs){
if(rs!=null){
try{
rs.close();
}catch(SQLException ex){
}
}
if(st!=null){
try {
st.close();
}catch(Exception ex){
}
}
if(conn!=null){
try{
conn.close();
}catch(Exception ex){
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dont-rush-the-team/test.git
git@gitee.com:dont-rush-the-team/test.git
dont-rush-the-team
test
电子公文传输系统
master

搜索帮助