资源简介
servlet+JSTL+JSP增删改查,简单的,很详细,初学者适合

代码片段和文件信息
package dao;
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 util.DBUtil;
import entity.Emp;
public class EmployeeDAO {
public Emp findById(int id) throws Exception{
Emp emp = null;
Connection conn = null;
PreparedStatement stat = null;
ResultSet ret = null;
try {
conn = DBUtil.getConnection();
String sql = “select * from emp e where e.id=?“;
stat = conn.prepareStatement(sql);
stat.setInt(1 id);
ret = stat.executeQuery();
if(ret.next()){
String name = ret.getString(“name“);
Double salary = ret.getDouble(“salary“);
Integer age = ret.getInt(“age“);
emp = new Emp();
emp.setId(id);
emp.setName(name);
emp.setSalary(salary);
emp.setAge(age);
}
} catch (SQLException e) {
// TODO: handle exception
e.printStackTrace();
} finally {
DBUtil.close(conn);
}
return emp;
}
public void deleteEmp(int id) throws Exception{
Connection conn = null;
PreparedStatement stat = null;
try {
conn = DBUtil.getConnection();
String sql = “delete from emp e where e.id =?“;
stat = conn.prepareStatement(sql);
stat.setInt(1 id);
stat.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
DBUtil.close(conn);
}
}
public void save(Emp emp){
Connection conn = null;
PreparedStatement stat = null;
try {
conn = DBUtil.getConnection();
String sql = “insert into emp(idname salary age) values(seq_emp.nextval???)“;
stat = conn.prepareStatement(sql);
stat.setString(1 emp.getName());
stat.setDouble(2 emp.getSalary());
stat.setInt(3 emp.getAge());
stat.executeUpdate();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
/**
* 查询所有员工信息
*/
public List findAll() throws Exception{
List employees =
new ArrayList();
Connection conn = null;
PreparedStatement stat = null;
ResultSet rst = null;
try {
conn = DBUtil.getConnection();
stat = conn.prepareStatement(
“SELECT * FROM emp“);
rst = stat.executeQuery();
while(rst.next()){
int id = rst.getInt(“id“);
String name = rst.getString(“name“);
double salary = rst.getDouble(“salary“);
int age = rst.getInt(“age“);
Emp e = new Emp();
e.setId(id);
e.setName(name);
e.setSalary(salary);
e.setAge(age);
employees.add(e);
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}finally{
DBUtil.close(conn);
}
return employees;
}
public void modify(Emp e) throws Exception{
Connection conn = null;
PreparedStatement stat = null;
try {
conn = DBUtil.getConnection();
stat = conn.prepareStatement(
“UPDATE emp SET name=?salary=?age=? WHERE id=?“);
stat.setString(1
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-06-18 11:02 test\
文件 841 2015-06-18 10:52 test\.classpath
文件 1037 2015-06-18 10:52 test\.project
目录 0 2015-06-18 10:52 test\.settings\
文件 503 2015-06-18 10:52 test\.settings\.jsdtscope
文件 364 2015-06-18 10:52 test\.settings\org.eclipse.jdt.core.prefs
文件 466 2015-06-18 10:52 test\.settings\org.eclipse.wst.common.component
文件 345 2015-06-18 10:52 test\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2015-06-18 10:52 test\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2015-06-18 10:52 test\.settings\org.eclipse.wst.jsdt.ui.superType.name
目录 0 2015-06-18 10:52 test\build\
目录 0 2015-06-19 09:16 test\build\classes\
目录 0 2015-06-19 09:16 test\build\classes\dao\
文件 4311 2015-06-19 09:16 test\build\classes\dao\EmployeeDAO.class
目录 0 2015-06-19 09:16 test\build\classes\entity\
文件 1528 2015-06-19 09:16 test\build\classes\entity\Emp.class
文件 781 2015-06-19 09:16 test\build\classes\entity\test1.class
目录 0 2015-06-19 09:16 test\build\classes\util\
文件 1495 2015-06-19 09:16 test\build\classes\util\DBUtil.class
目录 0 2015-06-19 09:16 test\build\classes\web\
文件 3921 2015-06-19 09:16 test\build\classes\web\ActionServlet.class
目录 0 2015-06-18 11:02 test\ddd\
文件 21128 2015-06-18 10:55 test\ddd\jstl.jar
文件 515490 2015-06-18 10:56 test\ddd\standard.jar
目录 0 2015-06-18 12:40 test\src\
目录 0 2015-06-18 12:39 test\src\dao\
文件 3267 2015-06-18 13:59 test\src\dao\EmployeeDAO.java
目录 0 2015-06-18 15:44 test\src\entity\
文件 708 2015-06-18 15:35 test\src\entity\Emp.java
文件 278 2015-06-18 15:45 test\src\entity\test1.java
目录 0 2015-06-18 11:35 test\src\util\
............此处省略50个文件信息
相关资源
- JSP购物网站完整源码包含项目源码,
- 使用JSTL需要的jar包程序文件
- jstl 和 standard jar 包
- 基于JSP的网上简易论坛
- jstl1.2和standard1.1.2jar包
- JSP图书管理系统源代码终结版
- 自己做的一个微博系统,高仿新浪的
- java servlet & jsp cookbook
- JAVAJSP在线收藏夹源码
- 关于一个基于jsp的BBS,带数据库
- jstl-1.2.jar 和 standard-1.1.2.jar 打包,亲
- 在线考试系统,oracle,jsp
- jstl-api-1.2.jar、jstl-impl-1.2.jar、mysql-c
- 在线考试系统,JSP+TOMCAT+JAVABEAN+JQUER
- jstl和standard
- Java图书管理系统,jsp+Servlet利用mvc模
- java,jsp,servlet音乐在线试听源程序
- BBS论坛基于jsp+mysql技术
- BBS系统,JSP做的
- JAVA农业网项目jsp
- Office在线编辑预览PageOffice
- java+jsp编写的购物网站
- java web标签chm版 包括struts1 struts2 jst
- 电子商务平台,jsp+servlet+javaBean MVC设
- Easyui,Echart,Jsp+Servlet开发简单完整
- jsp,Mysql,servlet,验证码为一体的简
- 通讯录管理系统JSP完成
- 交友平台毕业设计
- Android通过jsp后台连接Oracle数据库
- 中控指纹仪C#,jsp,js,ZKOnline SDK 5.
评论
共有 条评论