I have a program that retrieves a large dataset from Oracle 10g (10.2.0.3) using a fairly simple query. You can almost invoke the query / logic to βsortβ the sortings in that it selects columns from a table with a minimum sentence sentence (that is, returns most, if not all) of the rows.
The [Java] code is the template we all saw:
Connection con = null; PreparedStatement pstmt = null; ResultSet rs = null; try { con = getConnection(Person); pstmt = con.prepareStatement( "SELECT ID, FIRST_NAME, LAST_NAME, ... FROM PERSON WHERE ..."); rs = pstmt.executeQuery(); while (rs.next()) { // write the data to a file } } finally { if (rs != null) try { rs.close(); } catch (Exception e) { } if (pstmt != null) try {pstmt.close(); } catch (Exception e) { } if (con != null) try { con.close() ; } catch (Exception e) { } }
getConnection is my own method, which returns a Connection object to the Oracle database, which is used for the "PERSON" table. This seems like a question about worldly programming, but I wrote this code many times and never had this problem.
I get the message java.sql.SQLException: ORA-01406: the received column value was truncated on the while (rs.next ()) line. The Oracle documentation I read says: "The FETCH operation was forced to truncate a character string." He suggests using a larger column buffer to hold the largest column. But that does not make sense. Part of the above code is commented on as "write data to a file", I just write each column using rs.getBigDecimal ("ID"), rs.getString ("FIRST_NAME", etc.) I can reproduce the area using an empty while loop that does nothing with the ResultSet, that is, simply repeating with the ResultSet throws a SQLException.
The size of the returned dataset should be approximately 1 million rows. I get an exception after 600,000 lines / iterations through a loop. Any ideas?
source share