easyui结合java_jquery easyUI结合java实现用户的增删改查的实例分享

package com.java1234.dao;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import com.java1234.model.PageBean;

import com.java1234.model.User;

public class UserDao {

public ResultSet userList(Connection con,PageBean pageBean)throws Exception{

String sql="select * from t_user limit ?,?";

PreparedStatement pstmt=con.prepareStatement(sql);

pstmt.setInt(1, pageBean.getStart());

pstmt.setInt(2, pageBean.getRows());

return pstmt.executeQuery();

}

public int userCount(Connection con)throws Exception{

String sql="select count(*) as total from t_user";

PreparedStatement pstmt=con.prepareStatement(sql);

ResultSet rs=pstmt.executeQuery();

if(rs.next()){

return rs.getInt("total");

}else{

return 0;

}

}

public int userDelete(Connection con,String delId)throws Exception{

String sql="delete from t_user where id=?";

PreparedStatement pstmt=con.prepareStatement(sql);

pstmt.setString(1, delId);

return pstmt.executeUpdate();

}

public int userAdd(Connection con,User user)throws Exception{

String sql="insert into t_user values(null,?,?,?,?)";

PreparedStatement pstmt=con.prepareStatement(sql);

pstmt.setString(1, user.getName());

pstmt.setString(2, user.getPhone());

pstmt.setString(3, user.getEmail());

pstmt.setString(4, user.getQq());

return pstmt.executeUpdate();

}

public int userModify(Connection con,User user)throws Exception{

String sql="update t_user set name=?,phone=?,email=?,qq=? where id=?";

PreparedStatement pstmt=con.prepareStatement(sql);

pstmt.setString(1, user.getName());

pstmt.setString(2, user.getPhone());

pstmt.setString(3, user.getEmail());

pstmt.setString(4, user.getQq());

pstmt.setInt(5,user.getId());

return pstmt.executeUpdate();

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值