chenxianqin2 2017-12-23 02:45 采纳率: 100%
浏览 3042
已结题

sql,outside valid range for the datatype INTEGER.

Account在mysql数据库中类型为varchar(20).Account有个值是‘o001’.
使用dbutils,执行以下函数
public Ordinaryusers findUserByAccount(String Account) {
String sql="select * from ordinaryusers where Account='o001'";
try{
QueryRunner runner =new QueryRunner(DaoUtils.getSource());
return runner.query(sql, new BeanHandler(Ordinaryusers.class));
}catch(Exception e){
e.printStackTrace();
throw new RuntimeException(e);
}
}
报错:java.sql.SQLException: '1.7722222222E10' in column '5' is outside valid range for the datatype INTEGER.
采用普通连接数据库的方式调用以下函数
public Ordinaryusers findUserByAccount1(String Account) {
Connection connection = null;
PreparedStatement pStatement = null;
ResultSet rSet = null;
String sql="select * from ordinaryusers where Account='o001'";
Ordinaryusers obj = new Ordinaryusers();
try {
connection = Connect.getConnection();
pStatement = connection.prepareStatement(sql);
rSet = pStatement.executeQuery();
while(rSet.next()) {
obj.setAccount(rSet.getString(1));
obj.setPassword(rSet.getString(2));
}
}catch (Exception e) {
e.printStackTrace();
}finally {
try {
Connect.close(rSet, pStatement, connection);
}catch (Exception e) {
e.printStackTrace();
}
}
return obj;
}
就没有问题,实验了多次,发现第一个函数只要是o开头的数字就会出错,Account如果是其他字符串目前没问题,是不是dbutils框架里面有把字符串先转换为int的操作导致溢出?

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-12-23 02:47
    关注

    o不是8进制,0(零)才是,而且不要引号
    String sql="select * from ordinaryusers where Account=" +0001;

    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制