java.lang.OutOfMemoryError:超出GC开销限制 - MySQL

时间:2017-11-22 20:46:43

标签: java mysql garbage-collection

我有一个Java程序,它不断检查MySQL表的更新。

当它返回带有数据的ResultSet时,它会发出警报。

此代码目前正在运行约2小时,然后出错:

线程“main”中的异常java.lang.OutOfMemoryError:超出GC开销限制     在com.mysql.jdbc.MysqlIO.unpackField(MysqlIO.java:718)

Connection conn = DBClass.getConnection();

    while(true) {

    try {

        ResultSet rs = DBClass.getLatestArbs(conn);

        while(rs.next()) {

            String runnerName = rs.getString("RUNNER_NAME");        

            if(!sentAlerts.contains(runnerName)) {

                sendText(phoneNo, runnerName);
                sentAlerts.add(runnerName);

            }
        }

        rs.close();

    }catch(Exception ex) {
        ex.printStackTrace();
    }

DBClass.getLatestArbs(康涅狄格州):

    ResultSet rs = null;

    try {

        String query = "SELECT * FROM TABLE WHERE RUNNER_SCORE > 10 AND UPDATE_TSTAMP > DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 5 MINUTE)";

        // create the java statement
        Statement st = conn.createStatement();

        // execute the query, and get a java resultset
        rs = st.executeQuery(query);


    } catch (Exception e) {
        System.err.println("Got an exception! ");
        System.err.println(e.getMessage());
    }

    return rs;

0 个答案:

没有答案