java值byte类型长度超出

org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.apache. 在xml文件中碰到这样的报错的时候,有可能是你在里面使用了这种注释,编译会报错,可能这就是约定大于配置 org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='id', mode=IN 阅读详情

本人遇到的问题是mysql字段定义的是tinyint(3) unsigned  对应的java里面的是byte。 

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

[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代码如下:

 

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

Java byte 类型用法集合 throw new IllegalArgumentException("byte数组必须不为空,并且是2位!throw new IllegalArgumentException("byte数组必须不为空,并且是8位!throw new IllegalArgumentException("byte数组必须不为空,并且是2位!throw new IllegalArgumentException("byte数组必须不为空,并且是4位!结果是int,但是符号位是0,说明是正数,最后就是正整数234. 阅读详情

相关推荐

国民技术N32G45X低功耗问题之更改全局变量和栈在RAM中的地址

最近项目中用的MCU是国民技术的N32G45X,MCU的资源很丰富,RAM也很大,配套的库和例程也比较全,用起来还是不错的,但是在调试低功耗的时候还是费了不少劲。 首先由于项目低功耗需要,只能选择停机模式2(STOP2)。根据数据手册的描述,在此模式下外部低速时钟开启, RTC运行, R-SRAM保持,所有I/O状态保持,独立看门狗处于关闭状态,25℃的条件下电流为10个微安。 用的这款MCU的RAM是144KB,分为SRAM(128KB)和R-SRAM( Retention SRAM – 16KB),如果

狂想家 2485

idea运行Mybatis项目出现的常见错误(编码错误等)

java.lang.ExceptionInInitializerError....The error may exist in UserMapper.xml ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource UserMapper.xml

静水流深,沧笙踏歌 6656

Synopsys AXI VIP 从环境搭建到首个验证场景运行

本文详细介绍了Synopsys AXI VIP从环境搭建到首个验证场景运行的全过程,包括VIP安装、示例工程生成、验证环境解析、仿真调试技巧及进阶优化。特别针对AXI协议验证中的常见问题提供了实用解决方案,帮助工程师快速掌握这一SoC验证必备工具。

weixin_29185493的博客 340

tinyint对应java中什么类型_Java中的数据类型

Java的数据类型分为基本数据类型和引用数据类型一.基本数据类型:Java语言提供了八种基本类型。六种数字类型(四个整数型,两个浮点型),一种字符类型,还有一种布尔型。byte 数据类型是8位、有符号的,以二进制补码表示的整数;short 数据类型是 16 位、有符号的以二进制补码表示的整数int 数据类型是32位、有符号的以二进制补码表示的整数;long 数据类型是 64 位、有符号的以二进制补...

weixin_39609752的博客 2675

2026年AI技能进阶指南:从提示词工程到智能体开发实战

提示词工程作为AI时代的基础沟通技能,其核心原理是通过系统化的交互方法论实现与大模型的高效对话。这项技术通过明确性、具体性和可操作性的设计原则,显著提升了AI生成内容的质量和实用性。在工程实践层面,提示词工程已经发展出角色扮演、步骤分解等成熟模式,广泛应用于代码生成、技术方案设计等场景。随着AI智能体开发的兴起,提示词工程进一步演化为定义智能体身份认知和行为规范的系统接口设计,成为构建自主AI系统的关键技术基础。掌握从基础提示词到智能体开发的完整技能栈,能够帮助开发者在AI技术浪潮中保持核心竞争力。

weixin_33139275的博客 333

Ubuntu服务器通过IPV6端口转发搭建幻兽帕鲁私服实战

本文详细介绍了在Ubuntu服务器上通过IPV6端口转发搭建幻兽帕鲁私服的完整教程。针对只有公网IPV6地址的服务器环境,提供了从硬件检查、端口转发工具配置到游戏服务器安装的全流程解决方案,帮助玩家轻松实现多人联机游戏体验。

weixin_30652491的博客 490

MyBatis从入门到精通(十四):在MyBatis中使用类型处理器

最近在读刘增辉老师所著的《MyBatis从入门到精通》一书,很有收获,于是将自己学习的过程以博客形式输出,如有错误,欢迎指正,如帮助到你,不胜荣幸! 本篇博客主要讲解在MyBatis中如何使用类型处理器。 1. 明确需求 在设计之初,sys_role表的enabled字段有2个可选值,其中0 代表禁用,1代表启用,而且实体类中我们使用的是Interger类型: /** * 有效标志 ...

LIU18612105538的博客 333

SRAM compiler中Power Gating与Retention的实战配置指南

本文深入解析了在SRAM compiler中配置Power Gating(电源门控)与Retention(数据保持)功能的实战指南。针对低功耗芯片设计,文章详细阐述了如何根据应用场景(如移动AP、IoT设备)权衡开关类型、尺寸、唤醒时序以及保持电压,以实现静态功耗优化与数据可靠性的最佳平衡,并强调了后端实现与签核检查的关键要点。

weixin_29204121的博客 294

Java数据类型详解

Java数据类型基本数据类型int(整形)long(长整型)double(双精度浮点型)float(浮点型)short(短整型)char(字符型)byte(字节型)boolean(布尔型)注意事项 基本数据类型 int(整形) 整形类型,无论机器型号(因为有JVM,java的所有类型都是固定大小的),整形在java中占四个字节。 其对应的包装类: Integer 取值范围:-2147483648 -> 2147483647,如果赋值超出此范围会报错(如图) long(长整型) 大小:8个字节 对应的

Onen404的博客 763

华为OD机试真题 新系统 2026-04-26 Python&JS 实现【最大化游戏试玩资格分发】

新研发了一台游戏设备可以面向用户接受试玩。现有 n 个试玩申请,每个试玩有开始时间和结束时间。作为协调员,为了能让更多人体验到游戏,你需要对试玩申请进行选择,使得:

MISAYAONE的博客 290

【2024-06-21】网易互娱秋招实习笔试三道编程题解

恭喜发现宝藏!搜索公众号【TechGuide】回复公司名,解锁更多新鲜好文和互联网大厂的笔经面经。作者@TechGuide【全网同名】

试问道几许 1055

JAVA byte[]数组转long

最近在搞一个读取数据库日志,然后解析实时日志的程序,发现读取的日志id是number类型,但是得到的记录确实byte类型数组,因为byte类型的最大取值范围是-128到127,所以当number的值超出这个范围时候,byte数组就需要增加长度 byte占一个字节,如果不做处理直接付给int或long类型的变量,当高位为1时会导致得到不正确的值(负数), 如果与0xff(或者0xffL)做位与就可以保证得到byte本身的值。以下是byte和long对应的几个例子: byte[] lo...

beijiaoguzai的博客 4596

【WRF实操】四层嵌套网格设计-以粤港澳大湾区GBA为例

四层嵌套网格设计-以粤港澳大湾区GBA为例

WW、forever的博客 820

String index out of range: 6 越界问题

一般出现这个问题都发生在数组的获取中,原因是本身一个只有4个元素的数组,你截取了超过他本身就会出现越界的问题。之前刚开始学JAVA的时候有个问题特别的典型,就是把int a=1000 赋值给 byte b=a 就会出现越界的问题。原因就是byte所承受的是-128到127,1000大于了他所能承受的范围,所以越界。 ...

G_whang的博客 1万+

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

Java中两个byte类型相加结果赋值给byte类型的变量会报编译错误,byte加byte的结果为什么是int?

背景: 之前偶然看到有讨论这个问题,在网上搜了半天,结果都不尽如人意,解释没有到位, 有的说byte加byte默认就是int,那为什么这么做呢? 这不是找麻烦么?这种奇怪的默认还有哪些?带来一些列疑问。。。。。。 有的说byte存储的就是整型数据,这种说法的对错姑且不论,至少我觉得难免有点牵强了,还是疑问重重。。 所以今天专门总结一下: -------------------------...

the blog of alunSemiconductor 8694

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

JAVA byte 类型

JAVA byte 类型 不管什么数据,计算机最终存储的是二进制的0和1,每个二进制占1位(bit); 因为最早是老美发明的计算机,英语的所有字符使用8位二进制就能都表征了,所以老美规定了8位等于1字节(byte); 即是最早的ASCII编码; 比如字母a,占用1字节,即8个位的二进制(01),ASCII编码就是0110 0001,二进制对人类不友好,于是用数学里的进制转换,转为十进制的97,十六...

chenzl的专栏 2502

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

java byte数组最大长度是多少

使用eclipse默认的vm arguments,运行以下代码: public static void main(String[] args) { byte[] array=new byte[61858764]; // short[] shortArray=new short[30929382]; // int[] intArray=new int[15464691]; // long[] longArray=new long[7732345]; } 成功,没有报错,可知在eclipse默认的vm argu

岛田悠米 1万+

java中byte和byte类型的变量运算后赋值给byte类型的变量,为什么会报错?

首先我们知道,当byte和int类型的数据进行运算,编译时会把byte的变量的值提升为int类型再进行运算,这是如果你将他们二者的结果赋值给int类型的变量的话,即使没有溢出也会导致报错. 但是我们发现如果两个变量都是byte型的话,仍然会报错 原因可以从两个方面来解释. JVM中没有直接操作byte的指令, 在Java虚拟机中,对于大部分与数据类型相关的字节码指令,他们的操作码助记符中都有特...

i6223671的博客 4773

获取byte的各个bit值_Java中获取一个Byte 的各个Bit的值

在介绍具体方法之前,首先介绍两个概念:位(bit)和字节(byte)。计算机中以二进制来存储数据,二进制共有两个数:0和1。一个0或一个1即为1位。8位即为一个字节,字节为计算机存储空间的基本计量单位。一般,一个英文字符或数字占一个字节,一个汉字占2个字节。在各种语言中,数据类型都占用一定的存储空间,在Java中,各数据类型占用的空间情况如下:数据类型字节数据范围byte1个字节(8位)-128~...

weixin_39627697的博客 1752

Java中byte的符号位

在Java中byte类型是有符号的,而Java中又没有提供无符号的byte类型,因此在其表示范围为-128-127之间。而这样对于一些I/O处理程序来说需要对考虑符号位问题,通常的做法可能是:    int unsignedByte = signedByte >=0 ? signedByte : signedByte + 256;         这里我们发现,由于byte的符号位的关系,我们

jackwofe的专栏 1万+

Java中的byte类型

前言 在一次小项目中,使用了Java与QT进行TCP的通信,Java中只需要将要发送的字节数据写入OutputStream变量,然后write即可发送,但OutputStream.write只接受byte类型数据,若发送一个int数据则需要拆分为4个byte;Java的byte数据范围为-128~127,如果通过移位拆分出的字节变量值大于127,则write时,实际写入的字节为负数;如果接收端使用...

北京-大白的博客 1万+

Java中的byte

最近因为在做金融项目,里面对byte的操作要求比较多,所以在这里整理了一下关于Java中的byte类型。Java虚拟机中没有byte类型恩。。。怎么说呢,个人感觉这个说法有点儿唬人的意思。的确,当这个想法刚刚出现在我的脑海中的时候我觉得也有些胡扯,毕竟byte类型就在那里,怎么能说Java虚拟机中没有byte类型呢?好吧,我来稍稍的解释一下。Java虚拟机对基本类型的操作基本都是在栈上

netHibernate的专栏 3万+

[Java]获取byte数组的实际使用长度

背景:byte.length只能获取到初始化的byte数组长度,而不是实际使用的长度,因此想要获取到实际的使用长度只能靠其他方法实现。 方法一: public class ByteActualLength { public static int returnActualLength(byte[] data) { int i = 0; f...

aew95547的博客 2852

byte数组的实际使用长度

今天在编写java程序时发现了byte数组的一个有趣的现象,那就是当时用new String方式将byte数组转变为String时,byte数组中未被使用的部分('\0')仍然一同被转换为了String 1 byte[] bytes=new byte[1024]; 2 String s=new String(byte[]); 3 System.out.println(bytes...

aomilin4332的博客 1731

Java 任意长度byte数组转换为int数组

嗯。最近工程上遇到一个byte数组转换为int的问题,解决过程中遇到了几个坑,经过各种查资料终于还是解决了。撒花。 Java的位运算以及byte数组与其他类型数据的转换比c/c++感觉麻烦一些。这里简单说明一下byte数组和int的转换吧。 总所周知,int类型数据在Java中占据32 bit,byte占据8 bit,这样的话,正常情况下4个byte可以转换成一个int类型数据。 当然,不正

最萌fb 6086
上一篇: java之mvc接收postman传递list
下一篇: postman上传multipartfile
baicp3
博客等级 码龄16年 69粉丝 282原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值