0

I am trying to fetch 30 million records through Inputstream.read() suggested in Java SQL Result to InputStream. I'll be processing those records and transfering with GFT. when trying this process, I am getting java.sql.SQLException: ORA-01002: fetch out of sequence error on my resultset. but, it's not happening everytime. I see few success with 30,20 million records. sometimes, i get this error for 15 million records too. Out of sequence thrown after reading some records(not at beginning)

Following is how i am creating my connection & resultset

connection = dataSource.getConnection();
sql = "select query" // I am selecting 30 columns from table
stmt = connection.prepareStatement(sql); //using PreparedStatement
stmt.fetchSize() // It was set to 300.
rs = stmt.executeQuery(); //resultset
//Not overriding anymore default properties

Following are the properties in my config

spring.datasource.type: com.zaxxer.hikari.HikariDataSource
spring.datasource.driver-class-name: oracle.jdbc.OracleDriver

My oracle version: Oracle Database 12c Enterprise Edition Release

Is there anything i need to override the default connection/stmt/resultset properties? I am not sure, if it's related to connection. I am not able simulate/find out pattern when this was happening.

Query used was SELECT COLUMN_1, COLUMN_2, COLUMN_3....COLUMN_30 FROM TABLE_NAME where TIMESTAMP < ? and TIMESTAMP >= ? provided timestamps after creating preparedStatement stmt.setTimestamp(1, timestamp); stmt.setTimestamp(2, timestamp);

I was able to debug this once. onething i observed is resultset.next() is throwing this fetch out of sequence error. when i expand delegate object inside the resultset, observed fields are

isAllFetched = false
isDoneFetchingRows = false
currentRow = 7035999
fetchedrowCount = 7036000

This is the point where resultset.next() throwing Fetch out of sequence

0 Answers0