将oracle表写入文件时的JAVA-JDBC'Numeric Overflow'

时间:2018-08-17 14:13:34

标签: java jdbc

我有以下代码将oracle db值写入csv文件。 prining对于少量数据集工作正常,但对大量数据集显示以下错误

Error: Exception in thread "main" java.sql.SQLDataException: ORA-01426: numeric overflow

我正在使用以下代码将表格打印为CSV

//creating PreparedStatement object to execute query
        PreparedStatement preStatement;
        preStatement = connection.prepareStatement(sql);
        ResultSet result = preStatement.executeQuery();
        ResultSetMetaData rmsd = result.getMetaData();
        int Columncount = rmsd.getColumnCount();

//Get the column name and print the column name
        for (int iterator=1; iterator<= Columncount; iterator++) 
        {
            fw.append(rmsd.getColumnName(iterator)+",");
        }
        fw.append(LINE_SEP); //goto next line

//Print the data into excel using iteration
        while(result.next()){
            try {
                for (int jterator=1; jterator<=Columncount; jterator++){
                    fw.append(result.getString(jterator));
                    fw.append(',');
                }
                fw.append(LINE_SEP);

            } catch (SQLException e)
            {
                e.printStackTrace();
            }
            fw.flush();
            fw.flush();
        }
        System.out.println("Data is successfully written to "+conn.fileName);
        fw.close();
}

任何帮助将不胜感激。我还检查了我在下面使用并更新的查询的列类型和列类

Column 1 Type = 12 &     ColClass = java.lang.String
Column 2 Type = 12 &     ColClass = java.lang.String
Column 3 Type = 12 &     ColClass = java.lang.String
Column 4 Type = 12 &     ColClass = java.lang.String
Column 5 Type = 93 &     ColClass = java.sql.Timestamp
Column 6 Type = 93 &     ColClass = java.sql.Timestamp
Column 7 Type = 2  &     ColClass = java.math.BigDecimal
Column 8 Type = 2  &     ColClass = java.math.BigDecimal

0 个答案:

没有答案