Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2007
    Posts
    3

    Question Unanswered: java.sql.SQLException: Out of memory (Needed 268435428 bytes)

    I got exception :
    Caused by: java.sql.SQLException: Out of memory (Needed 268435428 bytes)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.ja va:2921)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.ja va:770)
    at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1288)
    at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.ja va:2258)
    at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:4 21)
    at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate
    (MysqlIO.java:1959)
    at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java :1384)
    at com.mysql.jdbc.ServerPreparedStatement.serverExecu te
    (ServerPreparedStatement.java:1133)
    at com.mysql.jdbc.ServerPreparedStatement.executeInte rnal
    (ServerPreparedStatement.java:670)
    at com.mysql.jdbc.PreparedStatement.executeQuery
    (PreparedStatement.java:1024)


    any idea????

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    sounds to me like you need more memory

    since you give no other information, i think that's about as much as i can offer
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    I would say that your dataset is so large the Java VM is running out of allocated memory, but as r937 clearly states you haven't really provided us with a huge amount of info there. Personally I would check the line numbers provided there.
    The number of bytes indicated by the error is 256Mb, so I would hazard a guess that you have a memory leak somewhere... Or your machine just doesn't have enough ram to cope with what you're doing. If your dataset is 256Mb that is pretty darned big...

  4. #4
    Join Date
    Apr 2007
    Posts
    3

    Exclamation

    The dataset is not at all big...
    As it is not a production DB, it has total 5 tables with not more than 20 records each.
    And the exception I said (java.sql.SQLException: Out of memory) is also not coming consistantly.

    Initially I too thought that the query might require more memory... but it is very simple select query. This 'Out of memory' seems misleading to me.

    Please respond,

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    my version of Microsoft® CrystalBall© says your join conditions are incorrect
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    I think what r937 is trying to say is post your SQL query and java code please...

  7. #7
    Join Date
    Apr 2007
    Posts
    3

    Question

    String loginSql = "SELECT COUNT(event_records_tbl.id) `total login`, " +
    "MIN(event_records_tbl.date) `first login`, " +
    "MAX(event_records_tbl.date) `last login`, " +
    "COUNT(DISTINCT event_records_tbl.date) `days` " +
    "FROM event_records_tbl " +
    "WHERE event_records_tbl.user_id = ? " +
    "AND " +
    "event_records_tbl.event_type = ? " +
    "AND event_records_tbl.date >= ? " +
    "AND event_records_tbl.date <= ? ";
    logger.info(loginSql);
    PreparedStatement pstmt = conn.prepareStatement(loginSql);
    pstmt.setString(1,userName);
    pstmt.setString(2,"LOGIN_EVENT");
    pstmt.setDate(3,startDate);
    pstmt.setDate(4,endDate);
    ResultSet rs = pstmt.executeQuery();


    the last statement of executeQuery is throwing the said exception.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •