chenxianqin2
chenxianqin2
2017-12-23 02:45

sql,outside valid range for the datatype INTEGER.

5
  • mysql
  • dnbutils

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条回答

为你推荐

换一换