package com.jredu.web.entity;
public class User {
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
private String userName;
private String pwd;
private String displayName;
public User(){}
public User(String userName, String pwd, String displayName) {
super();
this.userName = userName;
this.pwd = pwd;
this.displayName = displayName;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
}
package com.jredu.web.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.collections.map.HashedMap;
import com.jredu.web.dao.UserDao;
import com.jredu.web.entity.User;
public class UserServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public UserServlet() {
super();
}
/**
* Destruction of the servlet.
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet.
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
/**
* The doPost method of the servlet.
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setCharacterEncoding("utf-8");
request.setCharacterEncoding("utf-8");
response.setContentType("textml;charset=utf-8");
String action=request.getParameter("action");
if(null==action||action.equals("select")){
select(request,response);
}else if(action.equals("update")){
update(request,response);
}else if(action.equals("add")){
add(request,response);
}else if(action.equals("delect")){
delect(request,response);
}
}
//添加
public void add(HttpServletRequest request, HttpServletResponse response) throws IOException{
String userName=request.getParameter("userName");
String pwd=request.getParameter("pwd");
String displayName=request.getParameter("displayName");
User user=new User();
user.setUserName(userName);
user.setPwd(pwd);
user.setDisplayName(displayName);
UserDao userDao = new UserDao();
int affCount=userDao.insert(user);
PrintWriter out = response.getWriter();
out.print(affCount);
}
//删除
public void delect(HttpServletRequest request, HttpServletResponse response) throws IOException{
String ids[]=request.getParameterValues("uid[]");
UserDao userDao = new UserDao();
int affCount=0;
for(int i=0;i0){
from=rows*(pages-1);
}
UserDao userDao = new UserDao();
List list = userDao.selectPage(from,rows);
HashMap map=new HashMap();
map.put("total", userDao.selectCount());
map.put("rows", list);
PrintWriter out = response.getWriter();
JSONObject ja=JSONObject.fromObject(map);
//List list = userDao.selectAll();
//变成单个对象
//JSONObject jo=JSONObject.fromObject(user);
//把list变成JSONArray
//JSONArray ja = JSONArray.fromObject(list);
//PrintWriter out = response.getWriter();
System.out.println(ja.toString());
out.print(ja.toString());
}
/**
* Initialization of the servlet.
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
以教员和课程为例介绍一对多关联关系,在这里认为一个教员可以叫多门课程,而一门课程只有1个教员教,这种关系在实际中不太常见,通过教员和课程是多对多的关系。
示例数据:
地址表:
CREATE TABLE ADDRESSES
(
ADDR_ID INT(11) NOT NULL AUTO_INCREMENT,
STREET VAR
In this lesson we used the key "UITextAttributeTextColor" to change the color of the UINavigationBar appearance to white. This prompts a warning "first deprecated in iOS 7.0."
Ins
质数也叫素数,是只能被1和它本身整除的正整数,最小的质数是2,目前发现的最大的质数是p=2^57885161-1【注1】。
判断一个数是质数的最简单的方法如下:
def isPrime1(n):
for i in range(2, n):
if n % i == 0:
return False
return True
但是在上面的方法中有一些冗余的计算,所以
hbase(hadoop)是用java编写的,有些语言(例如python)能够对它提供良好的支持,但也有很多语言使用起来并不是那么方便,比如c#只能通过thrift访问。Rest就能很好的解决这个问题。Hbase的org.apache.hadoop.hbase.rest包提供了rest接口,它内嵌了jetty作为servlet容器。
启动命令:./bin/hbase rest s
下面这段sql本来目的是想更新条件下的数据,可是这段sql却更新了整个表的数据。sql如下:
UPDATE tops_visa.visa_order
SET op_audit_abort_pass_date = now()
FROM
tops_visa.visa_order as t1
INNER JOIN tops_visa.visa_visitor as t2
ON t1.