package com.my.mybatis; import java.util.List; import java.util.Map; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; public class TestMyBatis { static SqlSessionFactory sqlSessionFactory = null; static { sqlSessionFactory = MyBatisUtil.getSqlSessionFactory(); } public static void main(String[] args) { testAdd(); getUser(); getUserMap(); getUserMap1(); getUserCount(); } public static void testAdd() { SqlSession sqlSession = sqlSessionFactory.openSession(); try { UserMapper userMapper = sqlSession.getMapper(UserMapper.class); User user = new User("lisi", new Integer(25)); userMapper.insertUser(user); sqlSession.commit();// 这里一定要提交,不然数据进不去数据库中 } finally { sqlSession.close(); } } public static void getUser() { SqlSession sqlSession = sqlSessionFactory.openSession(); try { UserMapper userMapper = sqlSession.getMapper(UserMapper.class); User user = userMapper.getUser("zhanjindong1"); System.out.println("name: " + user.getName() + "|age: " + user.getAge()); } finally { sqlSession.close(); } } public static void getUserMap() { SqlSession sqlSession = sqlSessionFactory.openSession(); try { UserMapper userMapper = sqlSession.getMapper(UserMapper.class); List
运行结果:
Fri Apr 14 08:38:04 CST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. name: zhanjindong1|age: 18 userMap: [{name=lisi, id=5, age=25}, {name=lisi, id=6, age=25}, {name=lisi, id=7, age=25}, {name=lisi, id=8, age=25}, {name=lisi, id=9, age=25}, {name=lisi, id=10, age=25}, {name=lisi, id=11, age=25}, {name=lisi, id=12, age=25}, {name=lisi, id=13, age=25}, {name=lisi, id=14, age=25}, {name=lisi, id=15, age=25}, {name=lisi, age=25}, {name=lisi, age=25}] userMap1: [com.my.mybatis.Account@756e4d, com.my.mybatis.Account@e2abd, com.my.mybatis.Account@eff760, com.my.mybatis.Account@2f32ff, com.my.mybatis.Account@13f2bb1, com.my.mybatis.Account@e9a829, com.my.mybatis.Account@18a00e3, com.my.mybatis.Account@8b7f67, com.my.mybatis.Account@c7a4e4, com.my.mybatis.Account@178f375, com.my.mybatis.Account@c87b21, com.my.mybatis.Account@1375618, com.my.mybatis.Account@10399e] userCount: 2
附上全套源码:
1)package com.my.mybatis; public class Account { private int id; private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getId() { return id; } public void setId(int id) { this.id = id; }
}
2)package com.my.mybatis;
public class User {
private String name;
private Integer age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public User(String name, Integer age) {
super();
this.name = name;
this.age = age;
}
public User() {
super();
}
}
package com.my.mybatis;
import java.util.List;
import java.util.Map;
3)public interface UserMapper {
public void insertUser(User user);
public User getUser(String name);
public int getUserCount(String string);
public List> getUserCount1(String string);
public List> getUserMap(String string);
public List> getUserMap1(String string);
public List getUserMap2(String string);
public List> getUserCount2(String string);
public List> getUser1(String string);
}
--只包含执行部分的PL/SQL块
--set serveroutput off
begin
dbms_output.put_line('Hello,everyone!');
end;
select * from emp;
--包含定义部分和执行部分的PL/SQL块
declare
v_ename varchar2(5);
begin
select
转:http://stackoverflow.com/questions/6352208/how-to-solve-plugin-execution-not-covered-by-lifecycle-configuration-for-sprin
maven报错:
Plugin execution not covered by lifecycle configuration:
要使用MonkeyRunner,就要学习使用Python,哎
先抄一段官方doc里的代码
作用是启动一个程序(应该是启动程序默认的Activity),然后按MENU键,并截屏
# Imports the monkeyrunner modules used by this program
from com.android.monkeyrunner import MonkeyRun