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 请求分析基于spring boot+vue的前后端分离的项目
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?