自定义typeHandler
对于自定义typeHandler来说,需要在配置文件中注册typeHandlers 然后需要实现TypeHandler接口,
一个例子
首先编写调度的处理类
package com.ming.MyBatis; import org.apache.ibatis.type.JdbcType; import org.apache.ibatis.type.TypeHandler; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.sql.CallableStatement; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; public class StringTypeHandler implements TypeHandler<String> { private static Logger logger = LogManager.getLogger(); /** * 对预编译的Sql语句进行设置的时候, * @param ps * @param i * @param parameter * @param jdbcType * @throws SQLException */ @Override public void setParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType) throws SQLException { logger.info("使用TypeHandler"); // 设置预编译的sql对象,的string ps.setString(i, parameter); } /** * 获得结果的时候,获取到列名的时候,调度此方法 * @param rs * @param columnName * @return * @throws SQLException */ @Override public String getResult(ResultSet rs, String columnName) throws SQLException { logger.info("使用自定义类型,结果获取列名字符串"); return rs.getString(columnName); } /** * 获取结果集中的index * @param rs * @param columnIndex * @return * @throws SQLException */ @Override public String getResult(ResultSet rs, int columnIndex) throws SQLException { logger.info("在结果集中获取columnIndex"); return rs.getString(columnIndex); } /** * 获取结果集中的下标对应的字符串 * @param cs * @param columnIndex * @return * @throws SQLException */ @Override public String getResult(CallableStatement cs, int columnIndex) throws SQLException { logger.info("结果集中,下标获取到字符串"); return cs.getString(columnIndex); } }
再次编写配置文件
<typeHandlers> <typeHandler jdbcType="VARCHAR" javaType="string" handler="com.ming.MyBatis.StringTypeHandler"> </typeHandlers>
传入数据库的为的VARCHAR类型,javaType类型为string类型,调度的类为com.ming.MyBatis.StringTypeHandler
修改映射文件,说明那些需要对结果进行修改
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!-- 定义接口类 --> <mapper namespace="com.ming.MyBatis.POJO.RoleMapper"> <!-- id表示标签标识 type标识结果的返回类型,其中role为在配置文件中使用的别名 Role类 --> <resultMap type="role" id="roleMap"> <!-- id为主键映射关系 其中数据库中的id为主键 --> <id column="id" property="id" javaType="int" jdbcType="INTEGER"/> <!-- result为其他基本数据类型和实体类之间的映射 映射关系为role_name 到 roleName之间的映射 数据类型为string到VARCHAR之间的映射关系 --> <result column="role_name" property="roleName" javaType="string" jdbcType="VARCHAR"/> <!-- 这里使用typeHandler表示遇到此处理集的时候,将会执行com.ming.MyBatis.StringTypeHandler --> <result column="note" property="note" typeHandler="com.ming.MyBatis.StringTypeHandler"/> </resultMap> <!-- 书写SQL语句 定义使用resultMap为roleMap--> <select id="getRole" parameterType="int" resultMap="roleMap"> SELECT id, role_name, note FROM t_role4 WHERE id = #{id} </select> </mapper>
其中传入的参数为int类型,由于结果中mybatis没有int类型,对应的是INTEGER类型,在mysql中两者类型相同,所以修改如上所示,表类型
书写index.jsp
<%@ page import="org.apache.ibatis.session.SqlSession" %> <%@ page import="com.ming.Util.SqlSessionFactoryUtil" %> <%@ page import="com.ming.MyBatis.POJO.RoleMapper" %> <%@ page import="com.ming.MyBatis.POJO.Role" %> <html> <body> <h2>Hello World!</h2> <% long startTime = System.currentTimeMillis(); //获取开始时间 SqlSession sqlSession = null; Role role = null; for(int i = 0; i < 10; i++) { try { sqlSession = SqlSessionFactoryUtil.openSqlSesion(); RoleMapper roleMapper = sqlSession.getMapper(RoleMapper.class); role = roleMapper.getRole(100); sqlSession.commit(); } catch (Exception e) { e.printStackTrace(); sqlSession.rollback(); } finally { if (sqlSession != null) { sqlSession.close(); } } } long endTime = System.currentTimeMillis(); //获取结束时间 %> <%=role.getNote()%> </body> </html>
已经查询成功
查看日志文件,日志文件已经输出相关信息
2019-04-13 05:03:33.181 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection 2019-04-13 05:03:33.181 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool. 2019-04-13 05:03:33.182 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:33.235 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 2019-04-13 05:03:33.236 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer) 2019-04-13 05:03:33.275 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:33.276 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:33.277 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <== Total: 1 2019-04-13 05:03:33.277 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:33.312 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:33.312 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool. 2019-04-13 05:03:33.313 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection 2019-04-13 05:03:33.314 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool. 2019-04-13 05:03:33.314 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:33.346 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 2019-04-13 05:03:33.348 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer) 2019-04-13 05:03:33.386 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:33.390 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:33.391 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <== Total: 1 2019-04-13 05:03:33.395 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:33.442 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:33.443 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool. 2019-04-13 05:03:33.443 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection 2019-04-13 05:03:33.444 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool. 2019-04-13 05:03:33.444 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:33.479 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 2019-04-13 05:03:33.480 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer) 2019-04-13 05:03:33.518 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:33.519 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:33.520 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <== Total: 1 2019-04-13 05:03:33.520 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:33.556 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:33.557 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool. 2019-04-13 05:03:33.558 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection 2019-04-13 05:03:33.558 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool. 2019-04-13 05:03:33.558 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:33.591 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 2019-04-13 05:03:33.592 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer) 2019-04-13 05:03:33.638 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:33.639 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:33.640 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <== Total: 1 2019-04-13 05:03:33.640 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:33.676 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:33.677 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool. 2019-04-13 05:03:33.677 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection 2019-04-13 05:03:33.677 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool. 2019-04-13 05:03:33.677 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:33.711 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 2019-04-13 05:03:33.712 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer) 2019-04-13 05:03:33.747 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:33.748 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:33.748 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <== Total: 1 2019-04-13 05:03:33.749 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:33.780 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:33.780 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool. 2019-04-13 05:03:33.781 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection 2019-04-13 05:03:33.781 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool. 2019-04-13 05:03:33.781 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:33.830 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 2019-04-13 05:03:33.831 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer) 2019-04-13 05:03:33.868 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:33.870 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:33.870 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <== Total: 1 2019-04-13 05:03:33.872 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:33.913 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:33.914 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool. 2019-04-13 05:03:33.914 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection 2019-04-13 05:03:33.915 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool. 2019-04-13 05:03:33.915 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:33.956 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 2019-04-13 05:03:33.957 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer) 2019-04-13 05:03:33.994 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:33.994 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:33.995 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <== Total: 1 2019-04-13 05:03:33.995 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:34.029 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:34.029 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool. 2019-04-13 05:03:34.030 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection 2019-04-13 05:03:34.030 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool. 2019-04-13 05:03:34.030 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:34.095 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 2019-04-13 05:03:34.097 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer) 2019-04-13 05:03:34.133 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:34.133 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:34.134 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <== Total: 1 2019-04-13 05:03:34.134 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:34.168 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:34.169 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool. 2019-04-13 05:03:34.170 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection 2019-04-13 05:03:34.170 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool. 2019-04-13 05:03:34.171 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:34.214 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 2019-04-13 05:03:34.215 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer) 2019-04-13 05:03:34.252 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:34.252 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:34.253 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <== Total: 1 2019-04-13 05:03:34.254 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:34.291 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:34.291 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool. 2019-04-13 05:03:34.292 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:136) - Opening JDBC Connection 2019-04-13 05:03:34.292 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:397) - Checked out connection 197673257 from pool. 2019-04-13 05:03:34.292 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:34.336 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Preparing: SELECT id, role_name, note FROM t_role4 WHERE id = ? 2019-04-13 05:03:34.337 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - ==> Parameters: 100(Integer) 2019-04-13 05:03:34.379 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:34.380 [INFO ] com.ming.MyBatis.StringTypeHandler.getResult(StringTypeHandler.java:48) - 使用自定义类型,结果获取列名字符串 2019-04-13 05:03:34.380 [DEBUG] org.apache.ibatis.logging.jdbc.BaseJdbcLogger.debug(BaseJdbcLogger.java:143) - <== Total: 1 2019-04-13 05:03:34.381 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.resetAutoCommit(JdbcTransaction.java:122) - Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:34.415 [DEBUG] org.apache.ibatis.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:90) - Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@bc84129] 2019-04-13 05:03:34.415 [DEBUG] org.apache.ibatis.datasource.pooled.PooledDataSource.pushConnection(PooledDataSource.java:362) - Returned connection 197673257 to pool.
ps 类型转换的问题
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对小牛知识库的支持。
本文向大家介绍jQuery自定义滚动条完整实例,包括了jQuery自定义滚动条完整实例的使用技巧和注意事项,需要的朋友参考一下 本文实例讲述了jQuery自定义滚动条实现方法。分享给大家供大家参考,具体如下: 很多时候,由于美观上的考虑,往往需要自定义各种各样的滚动条,因此,本人做了一个demo 运行效果截图如下: 以下是代码部分: 希望本文所述对大家jQuery程序设计有所帮助。
问题内容: 我对二叉树有一些疑问: Wikipedia指出,当“完整的二叉树是其中所有级别(可能除了最后一个级别)均已完全填充且所有节点都位于最左侧”的二叉树时,该二叉树即已 完成 。最后的“越远越好”的段落是什么意思? 如果(1)它是空的,或者(2)它的左右子级是平衡的,并且左树的高度在以下高度的1之内,则格式正确的二叉树被称为“高度平衡”。正确的树,取自如何确定二叉树是否平衡?,这是正确的还是
问题内容: 如何通过“静态”方面和“动态”方面自定义的完成?静态方面是因为某些条目是已知的,并在构造时使用添加到了组合框文本中。动态方面是因为我还需要通过一些回调函数来完成,也就是说,一旦键入了几个字符,即在创建窗口小部件之后 动态地 完成。 我的应用程序使用的是Boehm的GC(当然不包括GTK对象),例如Guile或SCM或Bigloo。它可以看作是一种实验 性的持久性 动态类型的编程语言实现
7.5 子程序的完全定义 在7.1节所给出的子程序定义格式是一个最基本的、最简单的定义格式,它不能为子程序提供更简洁的调用方式。在宏汇编MASM 6.11系统中,为微机汇编语言的子程序提供了更加丰富的定义方式。 虽然子程序的这种定义方式显得稍微有点复杂,但它不仅为子程序的调用带来了极大的方便,而且其调用方式与高级语言中子程序的调用方式相一致,这就大大地降低了程序员熟练掌握它的难度。 7.5.1 子
本文向大家介绍Android自定义View叶子旋转完整版(六),包括了Android自定义View叶子旋转完整版(六)的使用技巧和注意事项,需要的朋友参考一下 上一篇实现多叶子飘动旋转,今天完成最后的功能。 1、添加右侧旋转枫叶 2、添加滑动条效果,显示百分比 3、修复叶子飘出边框问题 1、添加右侧旋转叶子 代码很明确,首先通过Matrix.postTranslate(float dx, floa
本文向大家介绍springboot与mybatis整合实例详解(完美融合),包括了springboot与mybatis整合实例详解(完美融合)的使用技巧和注意事项,需要的朋友参考一下 简介 从 Spring Boot 项目名称中的 Boot 可以看出来,Spring Boot 的作用在于创建和启动新的基于 Spring 框架的项目。它的目的是帮助开发人员很容易的创建出独立运行和产品级别的基于 Sp
staffMapper.xml staff.java: com.sut.util.Enumerate.MyBatis.GenericEnumUserType: 当调用getById方法时,它将引发异常:
我有一个要求,在那里我将从2列像天和月的数据,但我想把它转换成一个日期对象,并把它设置成我的bean类。 这是否可能不添加属性到java类? 我尝试检查自定义结果处理程序,但示例不够清晰。在从select方法返回之前,是否有钩子来运行某种自定义处理程序?