一、遇到的问题是这样的:

[RemoteTestNG] detected TestNG version 6.9.10
log4j: Parsing for [root] with value=[DEBUG,D,E,stepLog].
log4j: Level token is [DEBUG].
log4j: Category root set to DEBUG
log4j: Parsing appender named "D".
log4j: Parsing layout options for "D".
log4j: Setting property [conversionPattern] to [%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n].
log4j: End of parsing for "D".
log4j: Setting property [append] to [true].
log4j: Setting property [threshold] to [DEBUG].
log4j: Setting property [file] to [logs/logs.log].
log4j: setFile called: logs/logs.log, true
log4j: setFile ended
log4j: Appender [D] to be rolled at midnight.
log4j: Parsed "D" options.
log4j: Parsing appender named "E".
log4j: Parsing layout options for "E".
log4j: Setting property [conversionPattern] to [%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n].
log4j: End of parsing for "E".
log4j: Setting property [append] to [true].
log4j: Setting property [threshold] to [ERROR].
log4j: Setting property [file] to [logs/error.log].
log4j: setFile called: logs/error.log, true
log4j: setFile ended
log4j: Appender [E] to be rolled at midnight.
log4j: Parsed "E" options.
log4j: Parsing appender named "stepLog".
log4j: Parsing layout options for "stepLog".
log4j: Setting property [conversionPattern] to [%m%n].
log4j: End of parsing for "stepLog".
log4j: Setting property [file] to [logs/stepLog.log].
log4j: Setting property [append] to [true].
log4j: Setting property [threshold] to [INFO].
log4j: setFile called: logs/stepLog.log, true
log4j: setFile ended
log4j: Appender [stepLog] to be rolled at midnight.
log4j: Parsed "stepLog" options.
log4j: Finished configuring.
[TestNG] Running:
C:\Users\lenovo\AppData\Local\Temp\testng-eclipse-1408996642\testng-customsuite.xml

Begin executing test method[com.xueersi.qa.continuation.testcase.CouponCouponGetCouponListTest . Coupon_Coupon_getCouponList_test ()] in thread[1].

Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter.
PooledDataSource forcefully closed/removed all connections.
PooledDataSource forcefully closed/removed all connections.
PooledDataSource forcefully closed/removed all connections.
PooledDataSource forcefully closed/removed all connections.
Opening JDBC Connection
Created connection 1877986974.
Setting autocommit to false on JDBC Connection [com.mysql.jdbc.JDBC4Connection@6fefce9e]
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'type' from result set. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLDataException: '255' in column '4' is outside valid range for the datatype TINYINT.
### The error may exist in com/xes/qa/apitest/jcsj/db/mapper/Xes_couponsMapper.java (best guess)
### The error may involve com.xes.qa.apitest.jcsj.db.mapper.Xes_couponsMapper.getcouponList
### The error occurred while handling results
### SQL: SELECT id,name,code,type,valid_start_date,valid_end_date,face_value,order_full_price,receive_type,num,receive_start_time,receive_stime,receive_end_time,receive_etime, `status`,description,creater_id,create_time,modify_time FROM xes_coupons WHERE `receive_type` = 7 AND `status` = 3 AND `valid_start_date` <= SYSDATE() AND `valid_end_date` >= SYSDATE() AND `receive_stime` <= unix_timestamp(now()) AND `receive_etime` >= unix_timestamp(now()) ORDER BY `face_value` DESC, `id` DESC;
### Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'type' from result set. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLDataException: '255' in column '4' is outside valid range for the datatype TINYINT.
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:122)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:113)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:122)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:64)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)
at com.sun.proxy.$Proxy25.getcouponList(Unknown Source)
at com.xes.qa.apitest.jcsj.db.dbutils.DbUtils.getXesCoupuonsList(DbUtils.java:43)
at com.xueersi.qa.continuation.testcase.CouponCouponGetCouponListTest.Coupon_Coupon_getCouponList_test(CouponCouponGetCouponListTest.java:115)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
at org.testng.internal.MethodInvocationHelper$1.runTestMethod(MethodInvocationHelper.java:197)
at org.simfast.simpletester.unitils.SimpleTesterTestNG.run(SimpleTesterTestNG.java:244)
at org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:209)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:820)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1128)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:782)
at org.testng.TestRunner.run(TestRunner.java:632)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
at org.testng.SuiteRunner.run(SuiteRunner.java:268)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
at org.testng.TestNG.run(TestNG.java:1064)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'type' from result set. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLDataException: '255' in column '4' is outside valid range for the datatype TINYINT.
at org.apache.ibatis.type.BaseTypeHandler.getResult(BaseTypeHandler.java:68)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyAutomaticMappings(DefaultResultSetHandler.java:434)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:344)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:298)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:273)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:246)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:160)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:63)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:78)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:303)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:154)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:102)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:82)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:120)
... 34 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLDataException: '255' in column '4' is outside valid range for the datatype TINYINT.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.Util.getInstance(Util.java:387)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:898)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:887)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:862)
at com.mysql.jdbc.ResultSetImpl.throwRangeException(ResultSetImpl.java:7091)
at com.mysql.jdbc.ResultSetImpl.getByteFromString(ResultSetImpl.java:1712)
at com.mysql.jdbc.ResultSetImpl.getByte(ResultSetImpl.java:1659)
at com.mysql.jdbc.ResultSetImpl.getByte(ResultSetImpl.java:1671)
at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.ibatis.logging.jdbc.ResultSetLogger.invoke(ResultSetLogger.java:68)
at com.sun.proxy.$Proxy28.getByte(Unknown Source)
at org.apache.ibatis.type.ByteTypeHandler.getNullableResult(ByteTypeHandler.java:37)
at org.apache.ibatis.type.ByteTypeHandler.getNullableResult(ByteTypeHandler.java:26)
at org.apache.ibatis.type.BaseTypeHandler.getResult(BaseTypeHandler.java:66)
... 48 more
Resetting autocommit to true on JDBC Connection [com.mysql.jdbc.JDBC4Connection@6fefce9e]
Closing JDBC Connection [com.mysql.jdbc.JDBC4Connection@6fefce9e]
Returned connection 1877986974 to pool.
[Failed] CouponCouponGetCouponListTest.Coupon_Coupon_getCouponList_test(org.simfast.simpletester.core.TestData)[pri:0, instance:com.xueersi.qa.continuation.testcase.CouponCouponGetCouponListTest@5e316c74]
Report directory is :D:\sourcecode\new-test\target\SimpleTester
PooledDataSource forcefully closed/removed all connections.
FAILED: Coupon_Coupon_getCouponList_test(org.simfast.simpletester.core.TestData@d278d2b)
java.lang.NullPointerException
at com.xueersi.qa.continuation.testcase.CouponCouponGetCouponListTest.Coupon_Coupon_getCouponList_test(CouponCouponGetCouponListTest.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
at org.testng.internal.MethodInvocationHelper$1.runTestMethod(MethodInvocationHelper.java:197)
at org.simfast.simpletester.unitils.SimpleTesterTestNG.run(SimpleTesterTestNG.java:244)
at org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:209)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:820)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1128)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:782)
at org.testng.TestRunner.run(TestRunner.java:632)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
at org.testng.SuiteRunner.run(SuiteRunner.java:268)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
at org.testng.TestNG.run(TestNG.java:1064)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================

===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================

[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 6 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@77b52d12: 6 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@15975490: 5 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@4157f54e: 3 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@735f7ae5: 16 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@2c6a3f77: 19 ms

之前调通的代码一运行突然报了这样一堆的错,出错了不要紧看下问题出在哪里,于是仔细观察一番之后发现了这一堆报错中的关键信息,如下:

确定问题之后就到代码中去看看呗,代码如下:

mapper里面配置的代码如下:

model里面对应数据库字段的代码如下:

看来看去很简单的代码嘛,没什么错,这时候想到去数据库里看看吧

询问研发老师,果然这里的字段他们调整了,增加了101,102,255,看到255再回去看报错也是跟255有关系的,基本可以确定问题引发的原因了。

那么怎么解决呢?

二、解决办法


要解决问题得先理解下错误的具体原因:

1. 网上查询资料对jdbcType这个参数的描述不多,作用不清楚,大概的意思是“jdbcType这个参数的应用场景就是,当执行mapping文件的时候,有个映射的参数为空,那么无法确定他的类型,这个时候就需要jdbcType来确定类型“。

2. 既然jdbc Type是备用的那就不考虑调整了,于是解决思路放到了model里面的java代码上,获取到的资料如下:

mysql中的tinyint和java中的byte的数值范围是一样的(-128~127),如果你能保证自己存储的数值不会超过这个最大值是可以的,而且tinyint只有1字节。

既然数据库使用tinyint,肯定取值在tinyint的范围内。结果映射的时候是可以指定javaType的。 没必要使用默认的byte,完全可以用int,Integer。

看到这里基本就确定了问题的解决办法,其实就是byte类型是-128~127,而开发在库中新加入的255超出了这个范围所以导致出错,因此修改model代码如下:

调整完成再运行,果然问题解决了。

Mybatis使用-Error attempting to get column 'type' from result set. / '255' in column '4' is outside valid range for the datatype TINYINT.的更多相关文章

  1. com.mysql.jdbc.exceptions.jdbc4.MySQLDataException: '2.34435678977654336E17' in column '3' is outside valid range for the datatype INTEGER.

    ### Error querying database. Cause: java.lang.reflect.UndeclaredThrowableException### The error may ...

  2. org.springframework.jdbc.UncategorizedSQLException: Error attempting to get column 'alarmGroup' from result set. Cause: java.sql.SQLException: Error

    异常展示: org.springframework.jdbc.UncategorizedSQLException: Error attempting to get column 'alarmGroup ...

  3. Error attempting to get column from result set

    当使用mybatis plus3.2.0+springboot2.1.1 报错 Error attempting to get column from result set 1.一般出现这种问题,最简 ...

  4. 网站部署后Parser Error Message: Could not load type 的解决方案

    asp.net 的Webproject 项目是在64bit机上开发,默认选项发布后,部署到32bit的服务器上,出现Parser Error Message: Could not load type的 ...

  5. mysql 插入中文时出现ERROR 1366 (HY000): Incorrect string value: '\xC0\xEE\xCB\xC4' for column 'usern ame' at row 1

    1 环境: MySQL Server 6.0  命令行工具 2 问题 :  插入中文字符数据出现如下错误: ERROR 1366 (HY000): Incorrect string value: '\ ...

  6. error “base class has incomplete type”

    error "base class has incomplete type" 如果base.h是你的基类,那么在子类derive中,写成如下形式: class base; clas ...

  7. 0xc000000f: Error attempting to read the boot configuration data

    Get the fix to “0xc000000f: error attempting to read the boot configuration data” boot error for Win ...

  8. error: expected constructor, destructor, or type conversion before '.' token

    今天写代码是遇到这样一个问题error: expected constructor, destructor, or type conversion before '.' token:立马网上查,原来是 ...

  9. protocol error, got 'n' as reply type byte

    centos6.5上安装redis3.2版本,本地访问redis报错protocol error, got 'n' as reply type byte 解决办法 在redis配置文件redis.co ...

随机推荐

  1. MySQL-数据类型及选择

    一.数据类型 详见:http://www.runoob.com/mysql/mysql-data-types.html 二.类型选择 整形>date,time>enum,char>v ...

  2. 500 Days Of Summer

    <和莎莫的500天>,一部爱情片. Summer和Tom两人不同的爱情观走在了一起,或许真的就是爱情观不同,或许是Summer爱Tom爱的不够深,最终的结局是那么不尽人意. 有人愿意把秘密 ...

  3. map 容器(copy)

    Map是c++的一个标准容器,她提供了很好一对一的关系,在一些程序中建立一个map可以起到事半功倍的效果,总结了一些map基本简单实用的操作!1. map最基本的构造函数:   map<stri ...

  4. Problem D: 双向冒泡排序

    Problem D: 双向冒泡排序 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 447  Solved: 197[Submit][Status][We ...

  5. 解决session过期跳转到登录页并跳出iframe框架(或者layui弹出层)

    当用户长时间停留在管理界面没有操作,等到session过期后,进行了操作,那么只是iframe跳转到login页面,这不是我们想要的结果.解决方法:在login页面加一个逻辑判断: <scrip ...

  6. PAT (Advanced Level) Practise - 1093. Count PAT's (25)

    http://www.patest.cn/contests/pat-a-practise/1093 The string APPAPT contains two PAT's as substrings ...

  7. tensorfow install error

    http://stackoverflow.com/questions/33655731/error-while-importing-tensorflow-in-python2-7-in-ubuntu- ...

  8. sass安装更新及卸载方法

    在 Windows 平台下安装 Ruby 需要先有 Ruby 安装包,大家可以到 Ruby 的官网(http://rubyinstaller.org/downloads)下载对应需要的 Ruby 版本 ...

  9. 用JavaScript实现CheckBox的全选取消反选,及遮罩层中添加内容

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. hibernate系列之一

    通过自己不断的学习框架以及相关知识的学习,自己学会总结了学习路上遇到的一些问题以及疑惑,自己现在跟着相关的学习资料又进行了一些总结和实践,希望通过自己走过的学习之路能够帮助小伙伴们解决一些学习上问题或 ...