Out of range value for column 'id' at row 1问题

Out of range value for column 'id' at row 1问题

问题描述:

[code="java"]
private void execute(){
Statement st;

    try {
        //获取oracle链接
        oracleCONN=getOracleConnection();
        //获取MYSQL链接
        st = oracleCONN.createStatement();
        oracleRS=st.executeQuery("select bc.customerName,bc.landline,bc.telphone,sb.finishdate,sb.ShopCode,sb.DisCode from base_Customer bc,sale_SalesBill sb where trunc(bc.Created)=trunc(sysdate-1)and bc.saleBillid=sb.salesBillid");   
        String sql="insert into mix_end_user(name,tel,phone,time,officeName,storeName) values(?,?,?,?,?,?)";
        mySQLCONN=getMYConnection();
        ps = mySQLCONN.prepareStatement(sql);

// mySQLCONN.createStatement();
while(oracleRS.next()){
//开启事务
mySQLCONN.setAutoCommit(false);
ps.setString(1,oracleRS.getString("customerName"));
ps.setString(2, oracleRS.getString("landline"));
ps.setString(3, oracleRS.getString("telphone"));
ps.setDate(4, oracleRS.getDate("finishdate"));
ps.setString(5,oracleRS.getString("DisCode"));
ps.setString(6,oracleRS.getString("ShopCode"));
// System.out.println("insert into mix_end_user(name,tel,phone,time,officeName,storeName) values("+oracleRS.getString("customerName")+","+ oracleRS.getString("landline")+","+oracleRS.getString("telphone")+","+oracleRS.getDate("finishdate")+","+oracleRS.getString("DisCode")+","+oracleRS.getString("ShopCode")+")");
//提交
ps.executeUpdate();
mySQLCONN.commit();
}
} catch (SQLException e) {
e.printStackTrace();
//将异常信息写入配置文件
writeLOG(e);
try {
mySQLCONN.rollback();
} catch (Exception e1) {
e1.printStackTrace();
writeLOG(e);
}
}finally{
closeConnection();
}
}
[/code]
两个数据库 oracle取数据 mysql存数据
为什么回报这个错
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Out of range value for column 'id' at row 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2983)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3256)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1313)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1585)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1500)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1485)
at copy.user.CopyUser.execute(CopyUser.java:55)
at copy.user.CopyUser.main(CopyUser.java:25)

假如你的id是不是自增的,那么你得在insert的时候显示的插入id啊
但是你这个没加。

假如是自增的,你看一下自增量是多少,比如每次加1还是加多少,是不是这个设置的太大了,导致你的int不够接收假如是这样的话,你就设置bigint或者设置长度为更大(>11)就可以了。

希望能帮到你 不懂的可以站内问我。

可能你从oracle去过来的数据已经超出了mysql里面“id”字段所保存的范围

把“id”的数据类型改大些,比如“bigint”

你的 MySQL 的表的 ID 是自增的?
如果是的话,那么它应该是有个上限的,比如是 10000, 同时,假设你的那个表里当前没有数据,即ID将从1开始往上递增,那么,如果你的 Oracle 的表里的数据超过了 10000,那么,MySQL 的那个表就无法为多出来的数据自动分配 ID 号了,也就报了你这个错。
如果可以的话,你把ID的上限改大一点吧。