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

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 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题