• 保存报错:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'Infinity' in 'field list'


    18:04:27.576 [nioEventLoopGroup-3-2] WARN io.netty.channel.DefaultChannelPipeline - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'Infinity' in 'field list'
            at sun.reflect.GeneratedConstructorAccessor9.newInstance(Unknown Source)
            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:425)
            at com.mysql.jdbc.Util.getInstance(Util.java:408)
            at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:944)
            at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3933)
            at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3869)
            at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2524)
            at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2675)
            at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2465)
            at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1912)
            at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2133)
            at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2067)
            at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5175)
            at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2052)
            at com.iotest.nettyservice.service.NettyDiscardHandler2.channelRead(NettyDiscardHandler2.java:223)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
            at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:326)
            at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:313)
            at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:427)
            at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:281)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
            at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1422)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
            at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:931)
            at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
            at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:700)
            at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:635)
            at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:552)
            at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:514)
            at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1050)
            at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
            at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
            at java.lang.Thread.run(Thread.java:748)

    问题描述:我在研究netty时,对传入的字节数组进行接收、转换、处理后,存入mysql,在保存时报的错。奇怪的是,有时报错,有时不报错。

    分析过程:首先查看百度上各种解释,无非2种情况,1)sql写错,如缺少字段,使用系统自带占用词  2)sql传入类型和数据库类型不匹配

    但是不能解决问题,后来这个问题主要是通过Infinity这个词来分析解决的,该词代表无限,后来发现我要存的是mysql的float类型,但是我接到的是

    byte[] Flow_Total2 = {(byte)0x00,(byte)0x00,(byte)0x80,(byte)0x7F};
    这个4字节十六进制数组经过转换后的float值为Infinity,然后未经处理传入到sql所以存不进去。
    所以需要加入一个判断,填加后不再报错
    1 if(f2==Float.POSITIVE_INFINITY){
    2     f2=0.00f;
    3 }
  • 相关阅读:
    34. 在排序数组中查找元素的第一个和最后一个位置
    153. 寻找旋转排序数组中的最小值
    278. 第一个错误的版本
    540. 有序数组中的单一元素
    744. 寻找比目标字母大的最小字母
    69. x 的平方根
    763. 划分字母区间
    53. 最大子序和
    665. 非递减数列
    Zabbix探索:Agent配置中Hostname错误引起的Agent.Ping报错
  • 原文地址:https://www.cnblogs.com/Python5421/p/12196504.html
Copyright © 2020-2023  润新知