首页>代码>jsp+servlet开发java web网上花店商城系统,后台可配置化,方便修改,也可修改做成其他商城类项目>/FlowerShop/src/com/hr/dao/Basedao.java
package com.hr.dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Basedao {
static{
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static Connection getconn(){
Connection conn=null;
try {
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/db_flower_shop?useUnicode=true&characterEncoding=UTF-8","root","123456");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
}
public static void closeall(ResultSet rs,Statement ps,Connection conn){
try {
if(rs!=null)
rs.close();
if(ps!=null)
ps.close();
if(conn!=null)
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public static int exectuIUD(String sql,Object[] params){
int count=0;
Connection conn=Basedao.getconn();
PreparedStatement ps=null;
try {
ps=conn.prepareStatement(sql);
if(params!=null){
for (int i = 0; i < params.length; i++) {
ps.setObject(i+1, params[i]);
}
}
count=ps.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{
Basedao.closeall(null, ps, conn);
}
return count;
}
}
最近下载更多
翻斗花园胡英俊 LV2
2月7日
微信网友_7290996505972736 LV4
2024年12月11日
zolscy LV24
2024年11月28日
TY0165 LV20
2024年6月24日
阿九11111 LV4
2024年5月13日
pangzhihui LV14
2024年4月17日
阿时23428 LV15
2024年3月23日
微信网友_6786215447367680 LV5
2023年12月23日
hongdongdong LV14
2023年12月2日
tianshi LV7
2023年11月30日

最近浏览