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 ...
随机推荐
- angualejs
http://segmentfault.com/a/1190000000347412 http://www.xker.com/page/e2015/06/199141.html http://www. ...
- Lumen开发:lumen源码解读之初始化(2)——门面(Facades)与数据库(db)
版权声明:本文为博主原创文章,未经博主允许不得转载. 紧接上一篇 $app->withFacades();//为应用程序注册门面. $app->withEloquent();//为应用程序 ...
- 【v2.x OGE教程 11】 动画编辑器帮助文档
] 动画编辑器帮助文档 版本号 日期 作者 说明 1.0 2014-9-3 橙子游戏 文档创建 一.简单介绍 动画编辑器用于游戏动画的可视化编辑,支持序列帧动画和关键帧动画.通过解析生成的 ...
- 如何更好的利用Node.js的性能极限
通过使用非阻塞.事件驱动的I/O操作,Node.js为构建和运行大规模网络应用及服务提供了很好的平台,也受到了广泛的欢迎.其主要特性表现为能够处理庞大的并且高吞吐量的并发连接,从而构建高性能.高扩展性 ...
- Linux服务器性能日志收集和分析脚本(转)
最近老大要求分析服务器的性能数据,找到服务器运行的性能瓶颈,结果花了两天时间,写了两个脚本可以生成日志并可以进行数据提取,最终生成数据可以放到excel生成报表.过程中也学到了不少shell编程技术. ...
- Zookeeper数据与存储
一.前言 前面分析了Zookeeper对请求的处理,本篇博文接着分析Zookeeper中如何对底层数据进行存储,数据存储被分为内存数据存储于磁盘数据存储. 二.数据与存储 2.1 内存数据 Zooke ...
- Frobenius Norm
http://mathworld.wolfram.com/FrobeniusNorm.html
- Linux中rpm包管理器
包全名: 1.操作的包是没有安装的软件包时,使用全名,而且要注意路径 2.例如:jdk-8u131-linux-x64.rpm包名: 1.操作的是已经安装好的软件包,使用包名,是搜索/var/lib/ ...
- linux 中 开放端口,以及防火墙的相关命令
最近公司需要在 生产环境上线系统,碰到一些防火墙以及开放端口的问题,在此来 复习mark下 1.设定 [root@localhost ~]# /sbin/iptables -I INPUT - ...
- ubuntu 安装vagrant过程
Ubuntu安装vagrant时需要首先安装virtualBox. Step1: 在https://www.virtualbox.org/wiki/Linux_Downloads 下载ubuntu对应 ...