Re: java.sql.sqlException closed statement

From: sunilthumma (sunilthumma_at_hotmail.com)
Date: 08/11/04

  • Next message: sunilthumma: "Re: java.sql.sqlException closed statement"
    Date: Wed, 11 Aug 2004 11:24:31 -0400
    
    

    Hi,
        I am getting this Closed Statement exception intermittently.

    I am using prepared statement for multiple inserts in a loop.
    Using Weblogic 7.4 App server & Oracle 9i db.

    Here is the sample code i am using

                    Connection con = null;
                    PreparedStatement ps = null;
                    int result = 0;
                    try {
                            con = getConnection();
                            con.setAutoCommit(false);
                            ps = con.prepareStatement("INSERT INTO
    AUDIT(USER_ID,FIRST_NAME,LAST_NAME,CODE) VALUES(?,?,?,?)");
                            if(eCodes != null) {
                                    for(int i=0;i < eCodes.length;i++) {
                                            try {
                                                    ps.setString(1,user.getUserId());
                                                    ps.setString(2,user.getFirstName());
                                                    ps.setString(3,user.getLastName());
                                                    ps.setString(5,eCodes[i].getCode());
                                                    result = executeUpdate(ps);
                                            } catch(SQLException e) {
    // here the Closed Statement exception is coming
                                                    logger.error("[logUserActivity] error : "+ e.toString());
                                            } finally {
                                                    // if (ps != null)
                                                    // closeStatement(ps);
                                            }
                                    }
                                    con.commit();
                            }
                    } catch(SQLException e) {
                            logger.error("[logUserActivity] error : "+ e.toString());
                    } finally {
                            if (ps != null)
                                    closeStatement(ps);
                            if (con != null)
                                    closeConnection(con);
                    }

    Am I doing any mistake here ?
    Any help will be appreciated !!

    Thanks
    -Sunil


  • Next message: sunilthumma: "Re: java.sql.sqlException closed statement"