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

[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. 正则表达式---01 js篇

    本文主要针对js中正则表达式的实践操作,来让大家对正则表达式有一个入门清晰的了解. 正则表达式推荐学习网址:http://www.runoob.com/regexp/regexp-tutorial.h ...

  2. OpenSSL context 的几个参数

    NAME SYNOPSIS DESCRIPTION NOTES BUGS RETURN VALUES EXAMPLES SEE ALSO NAME SSL_CTX_set_verify, SSL_se ...

  3. pat甲级1016

    1016 Phone Bills (25)(25 分) A long-distance telephone company charges its customers by the following ...

  4. linux 命令——6 rmdir(转)

    今天学习一下linux中命令: rmdir命令.rmdir是常用的命令,该命令的功能是删除空目录,一个目录被删除之前必须是空的.(注意,rm - r dir命令可代替rmdir,但是有很大危险性.)删 ...

  5. hdu-1272 小希的迷宫---并查集或者DFS

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1272 题目大意: Problem Description 上次Gardon的迷宫城堡小希玩了很久(见 ...

  6. 【HDU4473】Exam(数学题)

    点此看题面 大致题意: 设\(f(x)=\sum[(a*b)|x]\),求\(\sum_{x=1}^nf(x)\). 转化题意 将题意进行转换,我们就可以发现,我们要求的\(ans\)就是满足\(x* ...

  7. URL Schemes 不能识别和不能跳转的原因

    在app跳转的过程中 需要设置url schemes后,但是设置完后,却不能识别, (测试方式:URL scheme + ://)在浏览器中打开,如果能打开app,就是能跳转 今天遇到了一个坑爹的问题 ...

  8. icon踩坑记录

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

  9. SpringBoot2.X最佳实践《一》 之 SpringBoot2.x初体验

    SpringBoot2.X最佳实践 前言 本系列文章,从零基础接触  SpringBoot2.x新版本,基础入门使用,热部署,到整合各个主流框架Redis4.x,消息队列AciveMQ, Rocket ...

  10. IBM MQ Explore使用

    一,版本说明: 系统:win10.MQ:V9.04 二.关于帮助文档: 1.读了差不多一大半,个人感觉说明的比较生僻,应该是直译过来的.但是还是可以从这里面学一下基本的操作. 2.对于一些基本的操作, ...