本帖最后由 CaptainGan 于 2011-07-06 01:12:32 编辑

解决方案 »

  1.   

    Cause An attempt was made to insert a value from a LONG datatype into another datatype. This is not allowed.  
    Action Do not try to insert LONG datatypes into other types of columns.  
      

  2.   

    ORA-01461: can bind a LONG value only for insert into a LONG column。
    这个异常已经很清楚了。
      

  3.   

    请大侠告诉我为什么在Eclipse中测试没有出现问题,打包成jar文件运行就有问题呢??
      

  4.   

    另外,我将异常全部贴出来供大家参考。
    java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a L
    ONG column        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
    :125)
            at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
            at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
            at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623)
            at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.
    java:181)
            at oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPreparedS
    tatement.java:543)
            at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStateme
    nt.java:1028)
            at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePrep
    aredStatement.java:2888)
            at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStat
    ement.java:2979)
            at com.elegon.dao.GetWrongBinaryRecordDao.insertRecordIntoTable(GetWrong
    BinaryRecordDao.java:53)
            at com.elegon.app.ExportMain.getBytesInsert(ExportMain.java:117)
            at com.elegon.app.ExportMain.main(ExportMain.java:187)
    java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a L
    ONG column        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
    :125)
            at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
            at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
            at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623)
            at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.
    java:181)
            at oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPreparedS
    tatement.java:543)
            at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStateme
    nt.java:1028)
            at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePrep
    aredStatement.java:2888)
            at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStat
    ement.java:2979)
            at com.elegon.dao.GetWrongBinaryRecordDao.insertRecordIntoTable(GetWrong
    BinaryRecordDao.java:53)
            at com.elegon.app.ExportMain.getBytesInsert(ExportMain.java:117)
            at com.elegon.app.ExportMain.main(ExportMain.java:187)
      

  5.   

    能贴出你的 sql代码以及相关的java代码吗  这样怎么看呀?
      

  6.   

    OK,相关代码如下:main入口类:
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.List;
    import java.util.Properties;import com.elegon.check.CheckInputsInfo;
    import com.elegon.dao.DbConnection;
    import com.elegon.dao.GetTaskRecordDao;
    import com.elegon.dao.GetWrongBinaryRecordDao;
    import com.elegon.entity.TaskInfoEntity;
    import com.elegon.entity.WrongBinaryEntity;
    import com.elegon.tools.Export2Excel;
    import com.elegon.tools.GetProperties;
    import com.elegon.tools.HelperMethod;public class ExportMain {
    private static Properties properties = (new GetProperties())
    .returnProperties();
    /**
     * 方法用于查找一打、二打以及核审是否相同,如果不相同,则将记录存入另外表格中
     * 
     * @param nowDate:当前日期
     */
    private static List<TaskInfoEntity> returnTheEqualRecords(String nowDate) {
    List<TaskInfoEntity> taskInfoList = new ArrayList<TaskInfoEntity>();
    List<TaskInfoEntity> tempTaskInfoList = new ArrayList<TaskInfoEntity>();
    taskInfoList = (new GetTaskRecordDao()).getWrongRecord(nowDate);
    if (taskInfoList != null) {
    for (int i = 0; i < taskInfoList.size(); i++) {
    String firstInputValue = taskInfoList.get(i)
    .getFirstInputValue();
    String secondInputValue = taskInfoList.get(i)
    .getSecondInputValue();
    String checkInputValue = taskInfoList.get(i)
    .getCheckInputValue();
    String[] strs = new String[]{firstInputValue, secondInputValue,
    checkInputValue};
    if (!(new CheckInputsInfo()).checkInputInfoEquals(strs)) {
    tempTaskInfoList.add(taskInfoList.get(i));
    }
    }
    }
    return tempTaskInfoList;
    } /**
     * 将不相同的录入记录插入到新表格中备份查询
     * 
     * @param taskinfoEntitiesList:保存有不相同录入值的实体List
     */
    private static boolean getBytesInsert(
    List<TaskInfoEntity> taskInfoEntitiesList) {
    boolean bool = false;
    List<WrongBinaryEntity> wBinaryEntitiesList = new ArrayList<WrongBinaryEntity>();
    if (taskInfoEntitiesList != null) {
    for (int i = 0; i < taskInfoEntitiesList.size(); i++) {
    String firstInputValue = taskInfoEntitiesList.get(i)
    .getFirstInputValue();
    String secondInputValue = taskInfoEntitiesList.get(i)
    .getSecondInputValue();
    String checkInputValue = taskInfoEntitiesList.get(i)
    .getCheckInputValue(); int firstInputBytesNum = 0;
    int secondInputBytesNum = 0;
    if (!(new CheckInputsInfo()).checkInputInfoEquals(new String[]{
    firstInputValue, secondInputValue, checkInputValue})) {
    firstInputBytesNum = CheckInputsInfo.returnDifferentBytes(
    taskInfoEntitiesList.get(i).getFirstInputValue(),
    taskInfoEntitiesList.get(i).getCheckInputValue()); secondInputBytesNum = CheckInputsInfo.returnDifferentBytes(
    taskInfoEntitiesList.get(i).getSecondInputValue(),
    taskInfoEntitiesList.get(i).getCheckInputValue()); WrongBinaryEntity wBinaryEntity = new WrongBinaryEntity();
    wBinaryEntity.setCustId(taskInfoEntitiesList.get(i)
    .getCustId());
    wBinaryEntity.setWTaskId(taskInfoEntitiesList.get(i)
    .getTaskId());
    wBinaryEntity.setWDocNum((new GetTaskRecordDao())
    .returnDocNum(taskInfoEntitiesList.get(i)
    .getDocId()));
    wBinaryEntity.setWFieldName(taskInfoEntitiesList.get(i)
    .getFieldName());
    wBinaryEntity.setWInput1Value(taskInfoEntitiesList.get(i)
    .getFirstInputValue());
    wBinaryEntity.setWInput2Value(taskInfoEntitiesList.get(i)
    .getSecondInputValue());
    wBinaryEntity.setWCheckValue(taskInfoEntitiesList.get(i)
    .getCheckInputValue());
    wBinaryEntity.setWInput1Name(taskInfoEntitiesList.get(i)
    .getFirstInputById());
    wBinaryEntity.setWInput2Name(taskInfoEntitiesList.get(i)
    .getSecondInputById());
    wBinaryEntity.setWCheckName(taskInfoEntitiesList.get(i)
    .getCheckInputById());
    wBinaryEntity.setInput1WrongBytesNum(firstInputBytesNum
    + "");
    wBinaryEntity.setInput2WrongBytesNum(secondInputBytesNum
    + "");
    wBinaryEntity
    .setWWrongBytes((firstInputBytesNum + secondInputBytesNum)
    + "");
    wBinaryEntity.setWRecordTime(taskInfoEntitiesList.get(i)
    .getRecordTime());
    wBinaryEntity.setWUpdateTime(taskInfoEntitiesList.get(i)
    .getUpdateTime());
    wBinaryEntity.setWIsTrue("FALSE");
    bool = (new GetWrongBinaryRecordDao())
    .insertRecordIntoTable(wBinaryEntity);
    }
    }
    }
    return bool;
    } // The input entrance
    public static void main(String[] args) {
    // 将错误的数据查询备份到另外表格中
    System.out.println("获得当前日期...");
    String nowDate = (new HelperMethod()).returnFormateDate((new Date()));
    List<TaskInfoEntity> taskInfolist = new ArrayList<TaskInfoEntity>();
    taskInfolist = returnTheEqualRecords(nowDate);
    System.out.println("开始备份数据...");
    boolean bool = getBytesInsert(taskInfolist);
    if (bool) {
    System.out.println("数据备份成功!");
    } else {
    System.out.println("数据备份失败!");
    }
    System.out.println("关闭数据库连接...");
    (new DbConnection()).CloseBPOESTConnection();
    (new DbConnection()).closeBPOSSARConnection();
    System.out.println("关闭数据库连接完成...");
    System.out.println("数据备份结束..."); }
    }
    向Oracle中插入记录的方法如下:
    /**
     * 向数据库中插入记录数据
     * 
     * @return boolean:向数据库中插入记录是否成功
     * @param wBinaryEntity:保存错误记录的实体类
     */
    public boolean insertRecordIntoTable(WrongBinaryEntity wBinaryEntity) {
    boolean bool = false;
    String sql = properties.getProperty("INSERT_RECORD_TO_WRONBYTES");
    try {
    PreparedStatement preparedStatement = connection
    .prepareStatement(sql);
    preparedStatement.setString(1, wBinaryEntity.getCustId());
    preparedStatement.setString(2, wBinaryEntity.getWTaskId());
    preparedStatement.setString(3, wBinaryEntity.getWDocNum());
    preparedStatement.setString(4, wBinaryEntity.getWFieldName());
    preparedStatement.setString(5, wBinaryEntity.getWInput1Value());
    preparedStatement.setString(6, wBinaryEntity.getWInput2Value());
    preparedStatement.setString(7, wBinaryEntity.getWCheckValue());
    preparedStatement.setString(8, wBinaryEntity.getWInput1Name());
    preparedStatement.setString(9, wBinaryEntity.getWInput2Name());
    preparedStatement.setString(10, wBinaryEntity.getWCheckName());
    preparedStatement.setString(11, wBinaryEntity
    .getInput1WrongBytesNum());
    preparedStatement.setString(12, wBinaryEntity
    .getInput2WrongBytesNum());
    preparedStatement.setString(13, wBinaryEntity.getWWrongBytes());
    preparedStatement.setString(14, wBinaryEntity.getWRecordTime());
    preparedStatement.setString(15, wBinaryEntity.getWUpdateTime());
    preparedStatement.setString(16, wBinaryEntity.getWIsTrue());
    bool = preparedStatement.execute();
    } catch (Exception e) {
    e.printStackTrace();
    }
    return bool;
    }
      

  7.   

    报错在哪一行,把那一行的java代码贴出来   表结构不大的话 ,也贴出来
      

  8.   

    这个问题已经解决了。我试验了下,是Orace driver版本对不上,换成Oracel对应的数据驱动就可以了。
      

  9.   

    ......oracle中最好不要用long类型,long类型有bug,无论在数据转换上还是数据迁移上。