📄 emppopedomdao.java
字号:
package com.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import com.bean.DepBean;
import com.bean.EmpPopedomBean;
import com.bean.PopedomBean;
import com.db.DBConnection;
import com.struts.form.EmpPopedomForm;
import com.struts.form.PopedomForm;
public class EmpPopedomDao implements IDao {
public boolean delete(String id) {
DBConnection dbconn = DBConnection.getDBConnection();
Connection conn = dbconn.getConn();
String sql = "delete from emppopedom where eid=?";
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps.setString(1, id);
int row = ps.executeUpdate();
if (row > 0) {
return true;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (ps != null) {
ps.close();
}
if (conn != null) {
conn.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return false;
}
public Object findById(String id) {
// TODO Auto-generated method stub
return null;
}
public Vector findByEid(String eid) {
DBConnection dbconn = DBConnection.getDBConnection();
Connection conn = dbconn.getConn();
String sql = "select p.* from popedom p,emppopedom ep where p.pid=ep.pid and ep.eid=?";
PreparedStatement ps = null;
ResultSet rst = null;
Vector vc = new Vector();
try {
ps = conn.prepareStatement(sql);
ps.setString(1, eid);
rst = ps.executeQuery();
while (rst.next()) {
//PopedomBean pd = new PopedomBean();
PopedomForm pd=new PopedomForm();
pd.setId(rst.getString(1));
pd.setName(rst.getString(2));
vc.add(pd);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (rst != null) {
rst.close();
}
if (ps != null) {
ps.close();
}
if (conn != null) {
conn.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return vc;
}
public boolean save(Object ob) {
DBConnection dbconn = DBConnection.getDBConnection();
Connection conn = dbconn.getConn();
String sql = "insert emppopedom values(?,?)";
//EmpPopedomBean epb = (EmpPopedomBean) ob;
EmpPopedomForm epb=(EmpPopedomForm) ob;
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps.setString(1, epb.getEid());
ps.setString(2, epb.getPid());
int row = ps.executeUpdate();
if (row > 0) {
return true;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (ps != null) {
ps.close();
}
if (conn != null) {
conn.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return false;
}
public boolean update(Object ob) {
// TODO Auto-generated method stub
return false;
}
public Vector findAll() {
// TODO Auto-generated method stub
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -