空闲时间接单代做的,一个java黑框配合交互数据库的程序。
现在看来算是个简易的jdbc工具,代码丢失了很多,不过最核心的还在。就是下面这个DBConnection,写个简单的方法调用这个就可以了。方法的作用注释上都写了。
没什么太大技术含量,不过已经满足课设的需求了、包括了一个自己写的jdbc连接工具和封装了一些访问数据库的基本方法。mysql版本当时是5.5,所以驱动是com.mysql.jdbc.Driver。实现了对邮件订单的增删改查,有基础的用户区分,登录注册功能等。
DBConnection:public class DBConnection
{
private String user = "root";
private String pwd = "";
private String url = "jdbc:mysql://localhost:3306/db20201111?characterEncoding=UTF-8";
private Connection conn=null;
static {
try {
Class.forName("com.mysql.jdbc.Driver");
//类加载 加载数据库驱动
}catch(ClassNotFoundException e)
{
e.printStackTrace();
}
}
public DBConnection()
{
try {
this.conn=DriverManager.getConnection(url, user, pwd);
}catch(SQLException e)
{
e.printStackTrace();
}
}
// select * from mission where missionNum = ? , date = 2 , location = 3 ;
//params [] = { 1 ,2 , 3};
public int executeUpdate( String sql,Object[] params )
{
PreparedStatement pstmt = null;
//mysql给出的处理sql语句的接口
//具有预处理功能
try{
pstmt=this.conn.prepareStatement(sql);
if(params!=null)
for(int i=0;i executeQuery(String sql, Object[] params)
{
PreparedStatement stmt=null;
ResultSet rs=null;
ArrayList 


