Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Number of Prepared Statements and JVM HeapSize

mKorbelOct 12 2010 — edited Oct 15 2014
on periodical (very short) bases I running Statement or PreparedStatement against MySql db (if isn't it thoroughly cleaned, then during the day I get "nice JavaHeap Memory")

if there way to get list of unclosed Statement(ResultSet) or PreparedStatement, similair way I load(write) from(to) db
    private void saveAppStatus(final String text) {
        Runnable doRun = new Runnable() {

            public void run() {
                try {
                    String addQuery = ("insert into sheduledtasks(Narrative) values (?)");
                    pstmt = DbConnection.dbConn.prepareStatement(addQuery);
                    pstmt.setString(1, text + " at: " + PassTime.getTime());
                    pstmt.executeUpdate();
                    try {
                        pstmt.close();
                        pstmt = null;
                    } catch (SQLException ex) {
                        Logger.getLogger(GuiFrame.class.getName()).log(Level.SEVERE, null, ex);
                        //JOptionPane.showMessageDialog(null, ex + "\n" + "Can't close Pstmt");
                    }
                } catch (Exception ex) {
                    Logger.getLogger(GuiFrame.class.getName()).log(Level.SEVERE, null, ex);
                    //JOptionPane.showMessageDialog(null, ex + "\n" + "Communications with Database or Table was broken");
                }
            }
        };
        SwingUtilities.invokeLater(doRun);
    }
This post has been answered by 796440 on Oct 12 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 12 2010
Added on Oct 12 2010
23 comments
276 views