package com.mybatis.po;
import java.io.Serializable;
import java.util.Date;
public class User implements Serializable {
private int id;
private String username;// 用户姓名
private String sex;// 性别
private Date birthday;// 生日
private String address;// 地址
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
@Override
public String toString() {
return "User [id=" + id + ", username=" + username + ", sex=" + sex
+ ", birthday=" + birthday + ", address=" + address + "]";
}
}
UserMapper.java是一个接口
package com.mybatis.mapper;
import java.util.List;
import com.mybatis.po.User;
public interface UserMapper {
//根据Id查找对象
public User findUserById(int id) throws Exception;
//模糊查找
public List findUserByLikeName(String username) throws Exception;
//添加对象
public void addUser(User user) throws Exception;
//修改对象
public void updateUser(User user) throws Exception;
}
UserMapper.xml
select LAST_INSERT_ID()
insert into user(username,birthday,sex,address) values(#{username},#{birthday},#{sex},#{address})
update user set username=#{username},birthday=#{birthday},sex=#{sex},address=#{address} where id=#{id}
delete from user where id=#{id}
Test测试
package com.mybatis.test;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Before;
import org.junit.Test;
import com.mybatis.mapper.UserMapper;
import com.mybatis.po.User;
public class TestMapper {
//定义工厂对象
private SqlSessionFactory sqlSessionFactory;
@Before
public void testCreateSqlsessionFactory()throws Exception {
//创建sqlsession工厂
sqlSessionFactory = new SqlSessionFactoryBuilder().build(Resources.getResourceAsStream("SqlMapConfig.xml"));
}
//根据Id查询用户对象
@Test
public void testFindUserById() {
//通过工厂对象生成sqlsession对象
SqlSession session = sqlSessionFactory.openSession();
UserMapper userMapper = session.getMapper(UserMapper.class);
try {
User user = userMapper.findUserById(10);
System.out.println(user);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//User user = session.selectOne("test.findUserById",10);//只能查询一条记录
//System.out.println(user);
session.close();
}
//模糊查询 根据名字
@Test
public void testFindUserByLikeName() {
//通过工厂对象生成sqlsession对象
SqlSession session = sqlSessionFactory.openSession();
//根据反射
UserMapper userMapper = session.getMapper(UserMapper.class);
try {
List userList = userMapper.findUserByLikeName("张");
System.out.println(userList.size());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
session.close();
}
//插入数据
@Test
public void testInsertUser() {
//通过工厂对象生成sqlsession对象
SqlSession session = sqlSessionFactory.openSession();
UserMapper userMapper = session.getMapper(UserMapper.class);
//创建用户对象
User user = new User();
user.setAddress("广西");
user.setBirthday(new Date());
user.setSex("1");
user.setUsername("legend");
//session.insert("test.insertUser", user);
try {
//动态代理实现插入数据
userMapper.addUser(user);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//实现事务提交
session.commit();
System.out.println("插入成功");
//session.close();
}
//修改信息
@Test
public void testUpdateUser() {
//通过工厂对象生成sqlsession对象
SqlSession session = sqlSessionFactory.openSession();
//User user = new User();
UserMapper userMapper = session.getMapper(UserMapper.class);
try {
//先查找数据库里面的数据 获得修改的对象
User user = userMapper.findUserById(10);
user.setId(26);
user.setAddress("广东广州");
user.setBirthday(new Date());
user.setSex("2");
user.setUsername("五仁");
//session.update("updateUser", user);
userMapper.updateUser(user);
session.commit();
System.out.println("更新成功");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//session.close();
}
//删除
@Test
public void testDelUser() {
//通过工厂对象生成sqlsession对象
SqlSession session = sqlSessionFactory.openSession();
session.delete("test.delUser", 28);
session.commit();
System.out.println("删除成功");
}
}
CMS概述
并发标记清理垃圾回收(Concurrent Mark and Sweep GC)算法的主要目标是在GC过程中,减少暂停用户线程的次数以及在不得不暂停用户线程的请夸功能,尽可能短的暂停用户线程的时间。这对于交互式应用,比如web应用来说,是非常重要的。
CMS垃圾回收针对新生代和老年代采用不同的策略。相比同吞吐量垃圾回收,它要复杂的多。吞吐量垃圾回收在执
1,找到配置文件
vi /etc/sysconfig/iptables
2,添加端口开放,增加一行,开放18081端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 18081 -j ACCEPT
3,保存
ESC
:wq!
4,重启服务
service iptables
使用Android SDK Manager 更新了Anadroid SDK Tooks 之后,
打开eclipse提示 This Android SDK requires Android Developer Toolkit version 23.0.0 or above, 点击Check for Updates
检测一会后提示 No update were found