/**
*
*/
package flexdemo;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
/**
*
*
*/
public class EmployeeManager {
/**
*
* @return
*/
public EmployeeManager(){
}
public List listEmployees() {
ArrayList list = new ArrayList();
Connection conn = null;
try {
conn = ConnectionManager.getConnection();
Statement stmt = conn.createStatement();
String sql = "select * from test";
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
Employee employee = new Employee(rs.getInt("id"), rs
.getString("name"), rs.getString("email"), rs
.getString("phone"), rs.getString("zipcode")
);
list.add(employee);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
ConnectionManager.closeConnection(conn);
}
return list;
}
/***************************************************************************
*
*
*
*
*
* @param employee
*/
public void addEmployee(Employee employee) {
Connection conn = null;
try {
conn = ConnectionManager.getConnection();
String sql = "insert into test(name,email,phone,zipcode) values(?,?,?,?)";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setString(1, employee.getName());
pstmt.setString(2, employee.getEmail());
pstmt.setString(3, employee.getPhone());
pstmt.setString(4, employee.getZipcode());
pstmt.execute();
} catch (SQLException e) {
e.printStackTrace();
} finally {
ConnectionManager.closeConnection(conn);
}
}
/**
*
*
*/
public void updateEmployee(Employee employee) {
Connection conn = null;
try {
conn = ConnectionManager.getConnection();
String sql = "update test set name=? ,email=?,phone=?,zipcode=? where email='"+employee.getEmail()+"'";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setString(1, employee.getName());
pstmt.setString(2, employee.getEmail());
pstmt.setString(3, employee.getPhone());
pstmt.setString(4, employee.getZipcode());
pstmt.execute();
} catch (SQLException e) {
e.printStackTrace();
} finally {
ConnectionManager.closeConnection(conn);
}
}
/**
*
*/
public void deleteEmployee(Employee employee) {
Connection conn = null;
try {
conn = ConnectionManager.getConnection();
String sql = "delete test where email='"+employee.getEmail()+"'";
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
} finally {
ConnectionManager.closeConnection(conn);
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
flex与后台交互的例子 flex工程.rar (40个子文件)
flexDemo
.project 2KB
flex_libs
.settings
org.eclipse.core.resources.prefs 88B
org.eclipse.wst.common.component 467B
org.eclipse.jdt.core.prefs 330B
org.eclipse.wst.common.project.facet.core.xml 269B
org.eclipse.jst.common.project.facet.core.prefs 288B
.mymetadata 297B
WebRoot
flexDemo.swf 238KB
employeelist.jsp 920B
AC_OETags.js 8KB
WEB-INF
web.xml 635B
lib
mysql-connector-java-3.1.13-bin.jar 446KB
classes
flexdemo
EmployeeManager.class 3KB
Employee.class 2KB
ConnectionManager.class 2KB
META-INF
MANIFEST.MF 39B
employeedelete.jsp 463B
employee.swf 508KB
history
history.js 24KB
historyFrame.html 807B
history.css 371B
playerProductInstall.swf 657B
employeeupdate.jsp 439B
employee.jsp 517B
flexDemo.html 4KB
employee.html 4KB
.actionScriptProperties 921B
html-template
AC_OETags.js 8KB
index.template.html 4KB
history
history.js 24KB
historyFrame.html 807B
history.css 371B
playerProductInstall.swf 657B
.myeclipse
src
flexdemo
ConnectionManager.java 1KB
EmployeeManager.java 3KB
Employee.java 1KB
.classpath 751B
flex_src
flexDemo.mxml 150B
employee.mxml 4KB
.flexProperties 211B
共 40 条
- 1
资源评论
无线技术小栈
- 粉丝: 14
- 资源: 35
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功