package dmsjdbc;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import domain.MatchedLogRec;
public class EmpDao {
private static final String findAll = "select logName,pid,loginTime,logoutTime,duration,logIP from emp";
//private static final String findAll1 = "select empno,ename,sal from (select empno,ename,sal,rownum n from emp where rownum<?) where n>=?";
//private static final String findBySal = "select empno,ename,sal from emp where sal=?";
private static final String insert = "insert into emp(logName,pid,loginTime,logoutTime,duration,logIP) values(?,?,?,?,?,?)";
private static final String update = "update emp set loginTime=?,logoutTime=?,duration=?,logIP=? where logName=? and pid=?";
private static final String delete = "delete from emp where logName=? and pid=?";
public List<MatchedLogRec> findAll() throws SQLException {
Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
con = ConnectionUtils.getConnection();
stmt = con.prepareStatement(findAll);
rs = stmt.executeQuery();
return toEmpList(rs);
} catch (SQLException e) {
e.printStackTrace();
throw e;
} finally {
ConnectionUtils.closeResultSet(rs);
ConnectionUtils.closeStatement(stmt);
ConnectionUtils.closeConnection();
}
}
/**
*
* @param page
* @param rowsPerPage
* @return
* @throws SQLException
*/
// public List<MatchedLogRec> findAll(int page, int rowsPerPage) throws SQLException {
// Connection con = null;
// PreparedStatement stmt = null;
// ResultSet rs = null;
// try {
// con = ConnectionUtils.getConnection();
// stmt = con.prepareStatement(findAll1);
// int start = (page - 1) * rowsPerPage + 1;
// int end = start + rowsPerPage;
// stmt.setInt(1, end);
// stmt.setInt(2, start);
// rs = stmt.executeQuery();
// return toEmpList(rs);
// } catch (SQLException e) {
// e.printStackTrace();
// throw e;
// } finally {
// ConnectionUtils.closeResultSet(rs);
// ConnectionUtils.closeStatement(stmt);
// ConnectionUtils.closeConnection();
// }
// }
/**
*
* @param sal
* @return
* @throws SQLException
*/
// public List<MatchedLogRec> findBySal(double sal) throws SQLException {
// Connection con = null;
// PreparedStatement stmt = null;
// ResultSet rs = null;
// try {
// con = ConnectionUtils.getConnection();
// stmt = con.prepareStatement(findBySal);
// stmt.setDouble(1, sal);
// rs = stmt.executeQuery();
// return toEmpList(rs);
// } catch (SQLException e) {
// e.printStackTrace();
// throw e;
// } finally {
// ConnectionUtils.closeResultSet(rs);
// ConnectionUtils.closeStatement(stmt);
// ConnectionUtils.closeConnection();
// }
// }
/**
*
* @param emp
* @throws SQLException
*/
public void insert(MatchedLogRec mlr) throws SQLException {
Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
con = ConnectionUtils.getConnection();
stmt = con.prepareStatement(insert);
stmt.setString(1, mlr.getLogName());
stmt.setString(2, mlr.getPid());
stmt.setString(3, mlr.getLoginTime());
stmt.setString(4, mlr.getLogoutTime());
stmt.setString(5, mlr.getDuration());
stmt.setString(6, mlr.getLogIP());
stmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
throw e;
} finally {
ConnectionUtils.closeResultSet(rs);
ConnectionUtils.closeStatement(stmt);
ConnectionUtils.closeConnection();
}
}
/**
*
* @param emp
* @throws SQLException
*/
public void update(MatchedLogRec mlr) throws SQLException {
Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
con = ConnectionUtils.getConnection();
stmt = con.prepareStatement(update);
stmt.setString(1, mlr.getLogName());
stmt.setString(2, mlr.getPid());
stmt.setString(3, mlr.getLoginTime());
stmt.setString(4, mlr.getLogoutTime());
stmt.setString(5, mlr.getDuration());
stmt.setString(6, mlr.getLogIP());
stmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
throw e;
} finally {
ConnectionUtils.closeResultSet(rs);
ConnectionUtils.closeStatement(stmt);
ConnectionUtils.closeConnection();
}
}
/**
*
* @param emp
* @throws SQLException
*/
public void delete(MatchedLogRec mlr) throws SQLException {
Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
con = ConnectionUtils.getConnection();
stmt = con.prepareStatement(delete);
stmt.setString(1, mlr.getLogName());
stmt.setString(2, mlr.getPid());
stmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
throw e;
} finally {
ConnectionUtils.closeResultSet(rs);
ConnectionUtils.closeStatement(stmt);
ConnectionUtils.closeConnection();
}
}
/**
*
* @param rs
* @return
* @throws SQLException
*/
private List<MatchedLogRec> toEmpList(ResultSet rs) throws SQLException {
List<MatchedLogRec> list = new ArrayList<MatchedLogRec>();
while (rs.next()) {
MatchedLogRec mlr = new MatchedLogRec();
mlr.setLogName(rs.getString(1));
mlr.setPid(rs.getString(2));
mlr.setLoginTime(rs.getString(3));
mlr.setLogoutTime(rs.getString(4));
mlr.setDuration(rs.getString(5));
mlr.setLogIP(rs.getString(6));
list.add(mlr);
}
return list;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
dms.zip_DMS项目_dms_dms 达内_达内_达内 dms
共71个文件
class:34个
java:30个
properties:4个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 121 浏览量
2022-09-24
08:13:29
上传
评论
收藏 62KB ZIP 举报
温馨提示
达内 dms项目 dms 数据分析和挖掘
资源推荐
资源详情
资源评论
收起资源包目录
dms.zip (71个子文件)
dms
bin
dms02T
RecordMatcher.class 3KB
RecordReader.class 3KB
RecordServer$QueueThread.class 1KB
RecordSender.class 898B
RecordServer.class 2KB
MatchedDao.class 4KB
DataUtil.class 2KB
ConnectionUtils.class 2KB
RecordServer$PollQueue.class 1KB
Main.class 551B
db.properties 189B
RecordGather.class 3KB
RecordReader$DataOffset.class 471B
Main2.class 2KB
domain
LogRec.class 1KB
MatchedLogRec.class 1KB
test
TestDataReader.class 2KB
outman
test
TestRecordMatcher.class 1KB
Main.class 1KB
TestRecordGather.class 563B
TestRecordReader.class 2KB
TestRec.class 3KB
Decode.class 2KB
dms
LogRec.class 1KB
Main.class 2KB
DataGet.class 2KB
DataReader.class 3KB
DataReader$DataOffset.class 454B
dmsjdbc
Order.class 2KB
IntegrateTask.class 1KB
EmpDao.class 4KB
OrderDao.class 3KB
ConnectionUtils.class 2KB
Main.class 1KB
db.properties 181B
Item.class 1KB
.settings
org.eclipse.jdt.core.prefs 629B
src
dms02T
Main2.java 2KB
MatchedDao.java 4KB
RecordGather.java 4KB
RecordSender.java 449B
RecordReader.java 3KB
db.properties 189B
RecordServer.java 2KB
ConnectionUtils.java 2KB
DataUtil.java 2KB
RecordMatcher.java 2KB
Main.java 179B
domain
MatchedLogRec.java 1010B
LogRec.java 788B
test
TestDataReader.java 879B
outman
test
TestRecordGather.java 264B
TestRecordMatcher.java 650B
TestRecordReader.java 873B
Main.java 1KB
Decode.java 2KB
TestRec.java 2KB
dms
DataReader.java 2KB
DataGet.java 1KB
LogRec.java 855B
Main.java 720B
dmsjdbc
EmpDao.java 6KB
OrderDao.java 2KB
Order.java 866B
db.properties 181B
ConnectionUtils.java 2KB
Item.java 638B
IntegrateTask.java 782B
Main.java 1KB
.project 379B
.classpath 524B
共 71 条
- 1
资源评论
- m0_631243692023-01-18资源内容详细全面,与描述一致,对我很有用,有一定的使用价值。
小贝德罗
- 粉丝: 69
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- MyBatis 动态 SQL:灵活而强大的查询构建器.pdf
- com.accordion.prettyo.apk
- 毕业设计:基于SSM的mysql-ssm软件bug管理系统(源码 + 数据库 + 说明文档)
- MTSQL8.0.35windows(64bit)-mysql-installer-community-8.0.35.0
- 人工智能引领音乐创作新时代之Suno AI
- Public-bicycle-usage-forecast-master.zip
- 通道处理过程模拟:从理论到实践.pdf
- 数据库第七次作业E-R图第一题
- 大厂面试真题Java语法基础面试专题及答案
- IMG20240428211124.jpg
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功