oracle读取ip_num用uint32_t接收,出错及解决

Posted 暴风城

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle读取ip_num用uint32_t接收,出错及解决相关的知识,希望对你有一定的参考价值。

 

start_ip_num = rset->getNumber(1);
end_ip_num = rset->getNumber(2);
2988 info_log("GetIpLibraryFromOracle data rset [%zu,%zu,%d] ",rset->getNumber(1),rset->getNumber(2),rset->getNumber(3));
src/ResultToDB.cpp:2988: warning: cannot pass objects of non-POD type ‘class oracle::occi::Number‘ through ‘...‘; call will abort at runtime 

 

 

ip_num是ip转成数字的32位无符号整数。我用uint32_t 来接收从oracle读取的start_ip_num 和end_ip_num ,然后打印到Log里。结果是[3395598328,46913028405240,242],第一个数是正确的,第二个是错误的,原本第一个数和第个二数要相同(数据库里是相同的)。


uint32_t start_ip_num = 0;
uint32_t end_ip_num = 0;
start_ip_num = rset->getNumber(1);
end_ip_num = rset->getNumber(2);
int departid= rset->getNumber(3);

2018-06-12 15:44:17 src/ResultToDB.cpp:2723|flow_discover <INFO>GetIpLibraryFromOracle start

2018-06-12 15:44:17 src/ResultToDB.cpp:2990|GetIpLibraryFromOracle <INFO>GetIpLibraryFromOracle data [339
5598328,46913028405240,242]

2018-06-12 15:44:17 src/ResultToDB.cpp:2990|GetIpLibraryFromOracle <INFO>GetIpLibraryFromOracle data [339
5596779,46913028403691,242]

2018-06-12 15:44:17 src/ResultToDB.cpp:2990|GetIpLibraryFromOracle <INFO>GetIpLibraryFromOracle data [339
5598326,46913028405238,242]

2018-06-12 15:44:17 src/ResultToDB.cpp:2990|GetIpLibraryFromOracle <INFO>GetIpLibraryFromOracle data [339
5596757,46913028403669,242]

2018-06-12 15:44:17 src/ResultToDB.cpp:2990|GetIpLibraryFromOracle <INFO>GetIpLibraryFromOracle data [339
5598327,46913028405239,242]

2018-06-12 15:44:17 src/ResultToDB.cpp:2725|flow_discover <INFO>GetIpLibraryFromOracle end size[0]

第一个rset->getNumber(1)对了,rset->getNumber(2);错了

 

用uint64_t 接收就第一个数和第个二数相同。

2018-06-12 15:50:23 src/ResultToDB.cpp:2723|flow_discover <INFO>GetIpLibraryFromOracle start

2018-06-12 15:50:23 src/ResultToDB.cpp:2990|GetIpLibraryFromOracle <INFO>GetIpLibraryFromOracle data [339
5598328,3395598328,242]

2018-06-12 15:50:23 src/ResultToDB.cpp:2990|GetIpLibraryFromOracle <INFO>GetIpLibraryFromOracle data [339
5596779,3395596779,242]

2018-06-12 15:50:23 src/ResultToDB.cpp:2990|GetIpLibraryFromOracle <INFO>GetIpLibraryFromOracle data [339
5598326,3395598326,242]

2018-06-12 15:50:23 src/ResultToDB.cpp:2990|GetIpLibraryFromOracle <INFO>GetIpLibraryFromOracle data [339
5596757,3395596757,242]

2018-06-12 15:50:23 src/ResultToDB.cpp:2990|GetIpLibraryFromOracle <INFO>GetIpLibraryFromOracle data [339
5598327,3395598327,242]

2018-06-12 15:50:23 src/ResultToDB.cpp:2725|flow_discover <INFO>GetIpLibraryFromOracle end size[0]

为什么用uint32_t 第一个是对的,用uint64_t 两个都是对的??我目前还没有找出答案!





















以上是关于oracle读取ip_num用uint32_t接收,出错及解决的主要内容,如果未能解决你的问题,请参考以下文章

如何在Java中获取与uint32_t对应的唯一值?

如何将字符串转换为 uint32_t [重复]

从uint32_t [16]数组到uint32_t变量序列的64位副本

Linux网络通信

为啥 uint32_t 与 uint64_t 速度不同?

uint8_t / uint16_t / uint32_t /uint64_t数据类型详解