用mysql做一个ip地下址库,把ip地址转换成long型后插到数据库(数据库该字段用的是bigint,文档中说有符号的范围是-9223372036854775808到9223372036854775807,无符号的范围是0到
18446744073709551615。),为什么在发生溢出先前用的是hibernate以为是hibernate有问题,改用jdbc插也不行发生溢出,变成负数了,改用unsiged也不行,呵呵,当然会不行,也只多一位
这是jdbc错误抛出异常:Exception in thread "main" java.sql.BatchUpdateException: Data truncation: Out of range value adjusted for column 'lstartip' at row 1
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1269)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:955)
at Initdata3.main(Initdata3.java:106)
探讨使用MySQL存储IP地址转换为Long类型时遇到的数据溢出问题,尝试通过不同方式解决,包括Hibernate和JDBC操作。
2981

被折叠的 条评论
为什么被折叠?



