package db;
import java.sql.*;
import java.util.*;
import bean.Operator;
public class OracleOperatorDAO implements OperatorDAO
{
private final String INSERT_AN_OPERATOR = "insert into TOperator values(?,?,?,?)";
private final String GET_ALL_OPERATORS = "select * from TOperator order by operator_id";
private final String GET_AN_OPERATOR = "select * from TOperator where operator_id=? and operator_pwd=?";
/**
*判断数据库中是否存在某个Operator
*/
public boolean isExists(Operator operator)
{
Connection conn = null;
PreparedStatement stmt = null;
boolean tmp = true;
try
{
conn = OracleDAOFactory.getConnection();
stmt = conn.prepareStatement(GET_AN_OPERATOR);
stmt.setString(1,operator.getOperator_ID());
stmt.setString(2,operator.getOperator_Pwd());
ResultSet result = stmt.executeQuery();
if(result.next())
tmp = true;
}
catch(SQLException e)
{
tmp = false;
}
finally
{
OracleDAOFactory.closeStatement(stmt);
OracleDAOFactory.closeConnection(conn);
}
return tmp;
}
/**
*插入一条operator记录
*/
public boolean createOperator(Operator operator)
{
Connection conn = null;
PreparedStatement stmt = null;
boolean tmp = true;
try
{
conn = OracleDAOFactory.getConnection();
stmt = conn.prepareStatement(INSERT_AN_OPERATOR);
stmt.setString(1,operator.getOperator_ID());
stmt.setString(2,operator.getOperator_Name());
stmt.setString(3,operator.getOperator_Pwd());
stmt.setString(4,operator.getIs_Admin());
int result = stmt.executeUpdate();
if(result != 1)
tmp = false;
}
catch(SQLException e)
{
tmp = false;
}
finally
{
OracleDAOFactory.closeStatement(stmt);
OracleDAOFactory.closeConnection(conn);
}
return tmp;
}
/**
*获得所有operator记录
*/
public Iterator getAllOperators()
{
Connection conn = null;
PreparedStatement stmt = null;
try
{
conn = OracleDAOFactory.getConnection();
stmt = conn.prepareStatement(GET_ALL_OPERATORS);
Operator operator = null;
ResultSet rs = stmt.executeQuery();
ArrayList operators = new ArrayList();
while(rs.next())
{
operator = new Operator();
operator.setOperator_ID(rs.getString("operator_id"));
operator.setOperator_Name(rs.getString("operator_name"));
operator.setOperator_Pwd(rs.getString("operator_pwd"));
operator.setIs_Admin(rs.getString("is_admin"));
operators.add(operator);
}
return operators.iterator();
}
catch(SQLException e)
{
e.printStackTrace();
return null;
}
finally
{
OracleDAOFactory.closeStatement(stmt);
OracleDAOFactory.closeConnection(conn);
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
mobile.rar (45个子文件)
mobile(部分参考实现)
newAccount.htm 8KB
newUser.htm 9KB
Resource.htm 9KB
WEB-INF
web.xml 1KB
classes
bean
Operator.class 891B
Operator.java 657B
db
DAOFactory.java 736B
OracleOperatorDAO.java 3KB
OperatorDAO.class 222B
OperatorDAO.java 412B
DAOFactory.class 498B
OracleOperatorDAO.class 2KB
OracleDAOFactory.class 2KB
OracleDAOFactory.java 2KB
mobile
servlet
LoginServlet.class 1KB
LoginServlet.java 1KB
modOperator.htm 9KB
ResourceMgr.htm 9KB
newCustomer1.htm 8KB
modifyOperator.htm 10KB
searchCustomer.htm 9KB
main.jsp 8KB
Charge.htm 9KB
newOperator.htm 9KB
images
blank.gif 43B
index_05.gif 3KB
index_06.gif 16KB
pic05.gif 7KB
index_03.gif 5KB
pic03.gif 6KB
Arrow1.gif 104B
pic04.gif 7KB
spacer.gif 43B
logo.gif 8KB
index_01.gif 35KB
blank(1).gif 43B
Thumbs.db 50KB
index_02.gif 8KB
pic02.gif 6KB
pic01.gif 6KB
index_04.gif 53KB
newCustomer.htm 8KB
index.html 3KB
style.css 3KB
comAccount.htm 8KB
共 45 条
- 1
资源评论
- weixin_410230802018-01-17木马病毒????
HBH20061
- 粉丝: 3
- 资源: 15
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功