Note that there are some explanatory texts on larger screens.

plurals
  1. POLimitations of MySQL JDBC
    primarykey
    data
    text
    <p>Problem:</p> <p>I get large ResultSet from DB(MySQL)(more than 1 000 000 rows) and handle each row about 40 seconds. Summary, i work with ResultSet more than 30 minutes, i get less records than really contain in database table аnd have no errors and no warrnings. If i count quantity of rows of that ResultSet, it's allright(quantity of ResultSet = quantity of DB).</p> <p>Is some limitations of mysql server or mysql jdbc driver or something else?</p> <p>My code. it works in spring framework :</p> <pre><code> public void query(String query, RowCallbackHandler rowCallbackHandler) throws SQLException { ResultSet rs = null; ResultSet rsCount = null; Statement stmt = null; Statement stmtCount = null; try { stmt = createStatmant(); rs = stmt.executeQuery(query); if (rs == null) { log.info("result set is null"); } stmtCount = createStatmant(); rsCount = stmtCount.executeQuery(query); int i = 0; while(rsCount.next()){ i++; } log.info("ResultSet size : "+i); int j = 0; rs.next(); do{ j++; rowCallbackHandler.processRow(rs); }while (rs.next()); log.info("ResultSet size real : "+i); log.info("ResultSet size fact : "+j); } catch (SQLException e) { throw new RuntimeException(e.getMessage()); }finally{ if(stmt!=null){ stmt.close(); } if(rs!=null){ rs.close(); } if(rsCount!=null){ rsCount.close(); } } } </code></pre> <p>createStatment :</p> <pre><code> private Statement createStatmant() throws SQLException { ((BasicDataSource)dataSource).setTimeBetweenEvictionRunsMillis(1000*60*60); Statement stmt = dataSource.getConnection().createStatement( ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); stmt.setFetchSize(fetchSize); stmt.setMaxRows(50000000-1); return stmt; } </code></pre> <p>datasource is global variable in class:</p> <pre><code> private javax.sql.DataSource dataSource; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload