Servlet简单增删改查
前台页面是别人给的。
例子:
package cn.itcast.cus.dao; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List; import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler; import cn.itcast.cus.domain.Customer;
import cn.itcast.jdbc.TxQueryRunner; public class CustomerDao {
private QueryRunner qr=new TxQueryRunner(); public void add(Customer customer){
String sql="INSERT INTO t_customer VALUES(?,?,?,?,?,?,?)";
Object[] params={customer.getCid(),customer.getCname(),customer.getGender(),customer.getBirthday(),customer.getCellphone(),customer.getEmail(),customer.getDescription()};
try {
qr.update(sql, params);
} catch (SQLException e) {
throw new RuntimeException(e);
}
} public List<Customer> findAll(){
String sql="SELECT * FROM t_customer";
ResultSetHandler<List<Customer>> rsh=new BeanListHandler<Customer>(Customer.class);
ArrayList<Customer> customers=null;
try {
customers = (ArrayList<Customer>) qr.query(sql, rsh);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return customers;
} public Customer load(String cid) {
String sql="SELECT * FROM t_customer WHERE cid=?";
ResultSetHandler<Customer> rsh=new BeanHandler<Customer>(Customer.class);
Object[] params={cid};
Customer customer=null;
try {
customer = qr.query(sql, rsh,params);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return customer;
} public void update(Customer c){
String sql="UPDATE t_customer SET cname=?,gender=?,birthday=?,cellphone=?,email=?,description=? WHERE cid=?";
Object[] params={c.getCname(),c.getGender(),c.getBirthday(),c.getCellphone(),c.getEmail(),c.getDescription(),c.getCid()};
try {
qr.update(sql, params);
} catch (SQLException e) {
throw new RuntimeException(e);
}
} public void delete(String cid) {
String sql="DELETE FROM t_customer WHERE cid=?";
Object[] params={cid};
try {
qr.update(sql, params);
} catch (SQLException e) {
throw new RuntimeException(e);
}
} public List<Customer> query(Customer c) {
StringBuilder sb=new StringBuilder("SELECT * FROM t_customer WHERE 1=1");
ArrayList<Object> params=new ArrayList<Object>(); String cname=c.getCname();
if(cname!=null&& !cname.trim().isEmpty()){
sb.append(" and cname like ?");
params.add("%"+cname+"%");
}
String gender=c.getGender();
if(gender!=null&&!gender.trim().isEmpty()){
sb.append(" and gender=?");
params.add(gender);
}
String cellphone=c.getCellphone();
if(cellphone!=null &&!cellphone.trim().isEmpty()){
sb.append(" and cellphone like ?");
params.add("%"+cellphone+"%");
}
String email=c.getEmail();
if(email!=null && !email.trim().isEmpty()){
sb.append(" and email like ?");
params.add("%"+email+"%");
}
String sql=sb.toString();
System.out.println(sql);
List<Customer> cus;
try {
cus=qr.query(sql, new BeanListHandler<Customer>(Customer.class),params.toArray());
} catch (SQLException e) {
throw new RuntimeException(e);
}
return cus;
}
} package cn.itcast.cus.dao; import org.junit.Test; import cn.itcast.cus.domain.Customer;
import cn.itcast.utils.CommonUtils; public class CustomerTest { @Test
public void fun1(){
CustomerDao dao=new CustomerDao();
for(int i=1;i<300;i++){
Customer c=new Customer();
c.setCid(CommonUtils.uuid());
c.setCname("cstnm_"+i);
c.setBirthday("2016-08-01");
c.setGender(i%2==0?"男":"女");
c.setCellphone("139"+i);
c.setEmail("cstm_"+i+"@163.com");
c.setDescription("我是客户"); dao.add(c);
}
} } package cn.itcast.cus.domain; import java.io.Serializable; public class Customer implements Serializable{ private static final long serialVersionUID = 1L;
/**
* 对应数据表
*/
private String cid;//主键
private String cname;//姓名
private String gender;//性别
private String birthday;//生日
private String cellphone;//电话
private String email;//邮箱
private String description;//描述
public Customer() {
super();
// TODO Auto-generated constructor stub
}
public Customer(String cid, String cname, String gender, String birthday,
String cellphone, String email, String description) {
super();
this.cid = cid;
this.cname = cname;
this.gender = gender;
this.birthday = birthday;
this.cellphone = cellphone;
this.email = email;
this.description = description;
}
public String getCid() {
return cid;
}
public void setCid(String cid) {
this.cid = cid;
}
public String getCname() {
return cname;
}
public void setCname(String cname) {
this.cname = cname;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getBirthday() {
return birthday;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public String getCellphone() {
return cellphone;
}
public void setCellphone(String cellphone) {
this.cellphone = cellphone;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public String toString() {
return "Customer [cid=" + cid + ", cname=" + cname + ", gender=" + gender
+ ", birthday=" + birthday + ", cellphone=" + cellphone
+ ", email=" + email + ", description=" + description + "]";
} } package cn.itcast.cus.service; import java.util.List; import cn.itcast.cus.dao.CustomerDao;
import cn.itcast.cus.domain.Customer; public class CustomerService {
private CustomerDao customerDao=new CustomerDao(); public void addCustomer(Customer customer){
customerDao.add(customer);
} public List<Customer> findAll(){
return customerDao.findAll();
} public Customer load(String cid){
return customerDao.load(cid);
} public void update(Customer c){
customerDao.update(c);
} public void delete(String cid) {
customerDao.delete(cid);
} public List<Customer> query(Customer c) {
return customerDao.query(c);
} } package cn.itcast.cus.web.servlet; import java.io.IOException;
import java.util.List; import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import cn.itcast.cus.domain.Customer;
import cn.itcast.cus.service.CustomerService;
import cn.itcast.servlet.BaseServlet;
import cn.itcast.utils.CommonUtils; public class CustomerServlet extends BaseServlet {
private static final long serialVersionUID = 1L;
CustomerService customerService=new CustomerService(); public String add(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
/*
* 1、补全表单数据到Customer对象
* 2、补全Cid,使用uuid
* 3、使用service方法完成添加工作
* 4.向request域中保存成功信息
* 5、转发到msg.jsp
*/
Customer c=CommonUtils.toBean(request.getParameterMap(), Customer.class);
c.setCid(CommonUtils.uuid());
customerService.addCustomer(c);
request.setAttribute("msg", "恭喜!注册成功");
return "f:/msg.jsp";
} public String findAll(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
/*
* 1、直接调用service方法,得到查询结果
* 2、查询结果保存到request域中
* 3、转发到list.jsp
*/
List<Customer> customers= customerService.findAll();
request.setAttribute("customers", customers);
return "f:/list.jsp";
} public String preEdit(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
/*
* 1、直接调用service方法,得到查询结果
* 2、查询结果保存到request域中
* 3、转发到EDIT.jsp
*/
String cid=request.getParameter("cid");
Customer c=customerService.load(cid);
request.setAttribute("customer", c);
return "f:/edit.jsp";
} public String edit(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
/*
* 1、封装表单数据到Customer对象中
* 2、调用service完成编辑
* 3、保存成功信息到request域
* 4、转发到msg.jsp显示成功信息
*/
Customer c=CommonUtils.toBean(request.getParameterMap(), Customer.class);
customerService.update(c);
request.setAttribute("msg", "恭喜,修改成功!");
return "f:/msg.jsp";
} public String delete(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
/*
* 1、封装表单数据到Customer对象中
* 2、调用service完成编辑
* 3、保存成功信息到request域
* 4、转发到msg.jsp显示成功信息
*/
String cid=request.getParameter("cid");
customerService.delete(cid);
request.setAttribute("msg", "恭喜,删除成功!");
return "f:/msg.jsp";
} public String query(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
/*
* 1、封装表单数据到Customer对象中
* 2、调用service完成编辑
* 3、保存查询到request域
* 4、转发到list.jsp
*/
Customer criteria=CommonUtils.toBean(request.getParameterMap(), Customer.class);
List<Customer> customers=customerService.query(criteria);
request.setAttribute("customers", customers);
return "f:/list.jsp";
} } <?xml version="1.0" encoding="UTF-8" ?>
<c3p0-config>
<!-- 默认连接配置 -->
<default-config>
<!-- 连接四大参数配置 -->
<property name="jdbcUrl">jdbc:mysql://127.0.0.1:3306/customers</property>
<property name="driverClass">com.mysql.jdbc.Driver</property>
<property name="user">guodaxia</property>
<property name="password">961012gz</property>
<!-- 池参数配置 -->
<property name="acquireIncrement">3</property>
<property name="initialPoolSize">10</property>
<property name="minPoolSize">2</property>
<property name="maxPoolSize">10</property>
</default-config> <named-config name="oracle-config">
<!-- 连接四大参数配置 -->
<property name="jdbcUrl">jdbc:oracle:thin:@localhost:1521:db</property>
<property name="driverClass">oracle.jdbc.driver.OracleDriver</property>
<property name="user">scott</property>
<property name="password">961012gz</property>
<property name="acquireIncrement">3</property>
<property name="initialPoolSize">10</property>
<property name="minPoolSize">2</property>
<property name="maxPoolSize">10</property>
</named-config> </c3p0-config>
后台代码
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>添加客户</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<link rel="stylesheet" type="text/css" href="<c:url value='/jquery/jquery.datepick.css'/>">
<script type="text/javascript" src="<c:url value='/jquery/jquery-1.5.1.js'/>"></script>
<script type="text/javascript" src="<c:url value='/jquery/jquery.datepick.js'/>"></script>
<script type="text/javascript" src="<c:url value='/jquery/jquery.datepick-zh-CN.js'/>"></script> <script type="text/javascript">
$(function() {
$("#birthday").datepick({dateFormat:"yy-mm-dd"});
}); function add() {
$(".error").text("");
var bool = true;
if(!$(":text[name=cname]").val()) {
$("#cnameError").text("客户名称不能为空");
bool = false;
}
if(!$("#male").attr("checked") && !$("#female").attr("checked")) {
$("#genderError").text("客户性别不能为空");
bool = false;
}
if(!$(":text[name=cellphone]").val()) {
$("#cellphoneError").text("手机不能为空");
bool = false;
}
if(!$(":text[name=email]").val()) {
$("#emailError").text("email不能为空");
bool = false;
}
if(bool) {
$("form").submit();
}
} </script>
<style type="text/css">
.error {color:red;}
</style>
</head> <body>
<h3 align="center">添加客户</h3>
<form action="<c:url value='/CustomerServlet'/>" method="post">
<!-- 向servlet传递一个名为method的参数,其值表示要调用servlet的哪一个方法 -->
<input type="hidden" name="method" value="add"/>
<table border="0" align="center" width="40%" style="margin-left: 100px;">
<tr>
<td width="100px">客户名称</td>
<td width="40%">
<input type="text" name="cname"/>
</td>
<td align="left">
<label id="cnameError" class="error"> </label>
</td>
</tr>
<tr>
<td>客户性别</td>
<td>
<input type="radio" name="gender" value="男" id="male"/>
<label for="male">男</label>
<input type="radio" name="gender" value="女" id="female"/>
<label for="female">女</label>
</td>
<td>
<label id="genderError" class="error"> </label>
</td>
</tr>
<tr>
<td>客户生日</td>
<td>
<input type="text" name="birthday" id="birthday" readonly="readonly"/>
</td>
<td>
<label id="birthdayError" class="error"> </label>
</td>
</tr>
<tr>
<td>手机</td>
<td>
<input type="text" name="cellphone"/>
</td>
<td>
<label id="cellphoneError" class="error"> </label>
</td>
</tr>
<tr>
<td>邮箱</td>
<td>
<input type="text" name="email"/>
</td>
<td>
<label id="emailError" class="error"> </label>
</td>
</tr>
<tr>
<td>描述</td>
<td>
<textarea rows="5" cols="30" name="description"></textarea>
</td>
<td>
<label id="descriptionError" class="error"> </label>
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="button" value="添加客户" onclick="add()"/>
<input type="reset" value="重置"/>
</td>
<td> </td>
</tr>
</table>
</form>
</body>
</html> <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>编辑客户</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<link rel="stylesheet" type="text/css" href="<c:url value='/jquery/jquery.datepick.css'/>">
<script type="text/javascript" src="<c:url value='/jquery/jquery-1.5.1.js'/>"></script>
<script type="text/javascript" src="<c:url value='/jquery/jquery.datepick.js'/>"></script>
<script type="text/javascript" src="<c:url value='/jquery/jquery.datepick-zh-CN.js'/>"></script> <script type="text/javascript">
$(function() {
$("#birthday").datepick({dateFormat:"yy-mm-dd"});
}); function add() {
$(".error").text("");
var bool = true;
if(!$(":text[name=cname]").val()) {
$("#cnameError").text("客户名称不能为空");
bool = false;
}
if(!$("#male").attr("checked") && !$("#female").attr("checked")) {
$("#genderError").text("客户性别不能为空");
bool = false;
}
if(!$(":text[name=cellphone]").val()) {
$("#cellphoneError").text("手机不能为空");
bool = false;
}
if(!$(":text[name=email]").val()) {
$("#emailError").text("email不能为空");
bool = false;
}
if(bool) {
$("form").submit();
}
} </script>
<style type="text/css">
.error {color:red;}
</style>
</head> <body>
<h3 align="center">编辑客户</h3>
<form action="<c:url value='CustomerServlet'/>" method="post">
<input type="hidden" name="method" value="edit">
<input type="hidden" name="cid" value="${customer.cid }">
<table border="0" align="center" width="40%" style="margin-left: 100px;">
<tr>
<td width="100px">客户名称</td>
<td width="40%">
<input type="text" name="cname" value="${customer.cname }"/>
</td>
<td align="left">
<label id="cnameError" class="error"> </label>
</td>
</tr>
<tr>
<td>客户性别</td>
<td>
<input type="radio" name="gender" value="男" id="male" <c:if test="${customer.gender eq '男' }">checked='checked'</c:if> />
<label for="male">男</label>
<input type="radio" name="gender" value="女" id="female" <c:if test="${customer.gender eq '女' }">checked='checked'</c:if>/>
<label for="female">女</label>
</td>
<td>
<label id="genderError" class="error"> </label>
</td>
</tr>
<tr>
<td>客户生日</td>
<td>
<input type="text" name="birthday" id="birthday" readonly="readonly" value="${customer.birthday }"/>
</td>
<td>
<label id="birthdayError" class="error"> </label>
</td>
</tr>
<tr>
<td>手机</td>
<td>
<input type="text" name="cellphone" value="${customer.cellphone }"/>
</td>
<td>
<label id="cellphoneError" class="error"> </label>
</td>
</tr>
<tr>
<td>邮箱</td>
<td>
<input type="text" name="email" value="${customer.email }"/>
</td>
<td>
<label id="emailError" class="error"> </label>
</td>
</tr>
<tr>
<td>描述</td>
<td>
<textarea rows="5" cols="30" name="description">${customer.description }</textarea>
</td>
<td>
<label id="descriptionError" class="error"> </label>
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="button" value="编辑客户" onclick="add()"/>
<input type="reset" value="重置"/>
</td>
<td> </td>
</tr>
</table>
</form>
</body>
</html> <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>主页</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head> <frameset rows="20%,*">
<frame src="<c:url value='/top.jsp'/>" name="top"/>
<frame src="<c:url value='/welcome.jsp'/>" name="main"/>
</frameset>
</html> <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:forward page="/frame.jsp" /> <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>客户列表</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head> <body>
<h3 align="center">客户列表</h3>
<table border="1" width="70%" align="center">
<tr>
<th>客户姓名</th>
<th>性别</th>
<th>生日</th>
<th>手机</th>
<th>邮箱</th>
<th>描述</th>
<th>操作</th>
</tr>
<c:forEach var="c" items="${requestScope.customers }">
<tr>
<td>${c.cname }</td>
<td>${c.gender }</td>
<td>${c.birthday }</td>
<td>${c.cellphone }</td>
<td>${c.email }</td>
<td>${c.description }</td>
<td>
<a href="<c:url value='/CustomerServlet?cid=${c.cid }&method=preEdit'/>">编辑</a>
<a href="<c:url value='/CustomerServlet?cid=${c.cid }&method=delete'/>">删除</a>
</td>
</tr>
</c:forEach>
</table>
</body>
</html> <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'msg.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head> <body>
<h1 style="color:green;" align="center">${msg }</h1>
</body>
</html> <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>高级搜索</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head> <body>
<h3 align="center">高级搜索</h3>
<form action="<c:url value='/CustomerServlet'/>" method="post">
<input type="hidden" name="method" value="query">
<table border="0" align="center" width="40%" style="margin-left: 100px;">
<tr>
<td width="100px">客户名称</td>
<td width="40%">
<input type="text" name="cname"/>
</td>
</tr>
<tr>
<td>客户性别</td>
<td>
<select name="gender">
<option value="">==请选择性别==</option>
<option value="男">男</option>
<option value="女">女</option>
</select>
</td>
</tr>
<tr>
<td>手机</td>
<td>
<input type="text" name="cellphone"/>
</td>
<td>
<label id="cellphoneError" class="error"> </label>
</td>
</tr>
<tr>
<td>邮箱</td>
<td>
<input type="text" name="email"/>
</td>
<td>
<label id="emailError" class="error"> </label>
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" value="搜索"/>
<input type="reset" value="重置"/>
</td>
<td> </td>
</tr>
</table>
</form>
</body>
</html> <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base target="main">
<title>My JSP 'top.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head> <body style="text-align: center;">
<h1>客户关系管理系统</h1>
<a href="<c:url value='/add.jsp'/>">添加客户</a> |
<a href="<c:url value='/CustomerServlet?method=findAll'/>">查询客户</a> |
<a href="<c:url value='/query.jsp'/>">高级搜索</a>
</body>
</html> <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'welcome.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head> <body>
<h1 align="center">欢迎登录本系统</h1>
</body>
</html>
jsp页面
js太恶心了就不传了,别人写的js总是有点看起来多。
感觉一些结构很清晰,很适合代码规范练习
Servlet简单增删改查的更多相关文章
- 最简单的jsp+servlet的增删改查代码
package ceet.ac.cn.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.s ...
- ado.net的简单数据库操作(三)——简单增删改查的实际应用
果然,在犯困的时候就该写写博客,写博客就不困了,哈哈! 上篇我记录了自己的SqlHelper的开发过程,今天记录一下如何使用这个sqlhelper书写一个具有简单增删改查的小实例啦. 实例描述:在数据 ...
- Redis:五种数据类型的简单增删改查
Redis简单增删改查例子 例一:字符串的增删改查 #增加一个key为ay_key的值 127.0.0.1:6379> set ay_key "ay" OK #查询ay_ke ...
- 国产化之路-统信UOS + Nginx + Asp.Net MVC + EF Core 3.1 + 达梦DM8实现简单增删改查操作
专题目录 国产化之路-统信UOS操作系统安装 国产化之路-国产操作系统安装.net core 3.1 sdk 国产化之路-安装WEB服务器 国产化之路-安装达梦DM8数据库 国产化之路-统信UOS + ...
- Mybatis实现简单增删改查
Mybatis的简单应用 学习内容: 需求 环境准备 代码 总结: 学习内容: 需求 使用Mybatis实现简单增删改查(以下是在IDEA中实现的,其他开发工具中,代码一样) jar 包下载:http ...
- idea+spring4+springmvc+mybatis+maven实现简单增删改查CRUD
在学习spring4+springmvc+mybatis的ssm框架,idea整合简单实现增删改查功能,在这里记录一下. 原文在这里:https://my.oschina.net/finchxu/bl ...
- Android_ADB 常用 shell命令 和 sqlite3 简单增删改查
今天学习了一个ADB的常用命令.接下来简单使用几个常用ADB shell 命令. 首先我们得明白什么是adb.exe ADB -Android Debug Bridge, 是 Android sdk ...
- MyBatis之二:简单增删改查
这一篇在上一篇的基础上简单讲解如何进行增删改查操作. 一.在mybatis的配置文件conf.xml中注册xml与注解映射 <!-- 注册映射文件 --> <mappers> ...
- 基于springmvc的简单增删改查实现---中间使用到了bean validation
package com.kite.controller; import java.util.HashMap; import java.util.Map; import javax.validation ...
随机推荐
- 【JMeter4.0】之 “jdk1.8、JMeter4.0” 安装与配置以及JMeter永久汉化和更改界面背景、并附加附录:个人学习总结
目录: 一.首先,需要安装.配置jdk 二.其次,安装.配置JMeter 三.JMeter汉化以及更改界面背景 四.附录:个人学习总结 一.首先,需要安装.配置jdk 返回目录 1.到官网下载1. ...
- unity视频教程
英雄联盟教程 http://pan.baidu.com/s/1i3rkMS9 密码:bv6r https://pan.baidu.com/share/link?shareid=258985 ...
- Spring IOC(通过实例介绍,属性与构造方法注入)
概括说明:下面通过实例介绍下属性方法注入.构造方法注入 1.源码结构图 2.代码介绍 (1).Dao接口 :UserDAO (2).Dao接口实现:UserDAOImpl (3).实体类:User ( ...
- Fiddler 详尽教程与抓取移动端数据包
转载自:http://blog.csdn.net/qq_21445563/article/details/51017605 阅读目录 1. Fiddler 抓包简介 1). 字段说明 2). Stat ...
- python 深复制与浅复制------copy模块
模块解读: 浅复制: x = copy.copy(y)深复制: x = copy.deepcopy(y)(注:模块特有的异常,copy.Error) 深copy与浅copy的差别主要体现在当有混合对象 ...
- Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [32,176] milliseco
有一次,我启动tomcat时,居然花费了33秒.我不理解为什么一个新的tomcat,需要这么久, 网上查找后,找到了一个解决方法. # vim /usr/local/tomcat/bin/catali ...
- iOS 微信支付点击左上角返回解决方案
在网了搜了一些解决方案,感觉并不是那么严谨,于是自己动手搞了一下,直接说思路 iOS调起第三方支付和安卓还不一样,安卓是把第三方的支付SDK直接镶嵌在自己的App中,而iOS由于沙盒机制,各个应用之间 ...
- Feign-独立使用-实战
目录 写在前面 1.1.1. 短连接API的接口准备 1.1.2. 申明远程接口的本地代理 1.1.3. 远程API的本地调用 写在最后 疯狂创客圈 亿级流量 高并发IM 学习实战 疯狂创客圈 Jav ...
- java对IO的操作
import java.io.*; public class HelloWorld { //Main method. public static void main(String[] args) { ...
- 我的Android进阶之旅------>介绍一款集录制与剪辑为一体的屏幕GIF 动画制作工具 GifCam
由于上一篇文章:我的Android进阶之旅------>Android之动画之Frame Animation实例 中展示的是Frame动画效果,但是之前我是将图片截取下来,不好说明确切的动画过程 ...