我们可以这样来写一个select statement:

1
<select id="selectById" parameterType="int" resultType="com.user.pojo.UserPojo">
2
  select id,name,create_time from user where id= #{id}
3
</select>
阅读全文 »

要求不高的话,SqlMapConfig.xml可以是这样的:

1
<!DOCTYPE configuration PUBLIC
2
  "-//mybatis.org//DTD Config 3.0//EN"
3
  "http://mybatis.org/dtd/mybatis-3-config.dtd">
4
<configuration>
5
  <environments default="development">
6
    <environment id="development">
7
      <transactionManager type="JDBC" />
8
      <dataSource type="POOLED">
9
        <property name="driver" value="com.mysql.jdbc.Driver" />
10
        <property name="url" value="jdbc:mysql://localhost:3306/mybatis?characterEncoding=utf-8" />
11
        <property name="username" value="root" />
12
        <property name="password" value="" />
13
      </dataSource>
14
    </environment>
15
  </environments>
16
  <mappers>
17
    <mapper resource="mybatis/mapper/UserMapper.xml" />
18
  </mappers>
19
</configuration>
阅读全文 »