Mantis - Resin
Viewing Issue Advanced Details
2708 minor always 05-29-08 13:45 06-18-08 15:55
ferg  
ferg  
urgent  
closed 3.1.6  
fixed  
none    
none 3.1.7  
0002708: databases, sqlexceptions, and xa
(rep by Takahiro Fukuda)


The following phenomenon is bug?

1. Some SQLs are executed in the same transaction.
2. Each SQL gets and close connection.
3. Even if SQLException occurs, next SQL is executed.
4. The number of max-connections SQLException occurs, next connection
  cannot be got.

I think the connection which occurs SQLException is not closing.

I attach sample program.
Please set max-connections is 20.


    try{
        ((UserTransaction) new InitialContext().lookup("java:comp/UserTransaction")).begin();
        for(int i = 0 ; i < 30 ; ++i) {
            Connection connection = null;
            PreparedStatement statement = null;
// String sql="INSERT INTO b_m_image_icon(image_icon_cd,login_type,user_cd,src,sort_key,record_date) VALUES('account_license_sett','group',null,'images/menu/account_license_setting.jpg',0,'2006/08/11|00:00:00')";
            String sql="select * from b_m_account_bx";
            try {

                System.out.println(i + "################### get connection start ######################");
           // connection = DatabaseManager.getInstance().getLoginGroupConnection("default");
                connection = ((DataSource)new InitialContext().lookup("java:comp/env/jdbc/oracle")).getConnection();
                System.out.println("################### get connection end ######################");

                System.out.println("################### get prepareStatement start ######################");
// statement = connection.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                statement = connection.prepareStatement(sql);
                System.out.println("################### get prepareStatement end ######################");

                System.out.println("################### get execute start ######################");
                statement.execute();
                System.out.println("################### get execute end ######################");

            } catch (SQLException e) {
                System.out.println(e.getMessage());
            } finally {
                try {
                    if (statement != null) {
                        statement.close();
                        statement = null;
                    }
                    if (connection != null) {
                        connection.close();
                        System.out.println("----------- close " + connection.isClosed() + " -----------");
                        connection = null;
                    }
                } catch (SQLException e1) {
                    e1.printStackTrace();
                }
            }
        }
        ((UserTransaction) new InitialContext().lookup("java:comp/UserTransaction")).commit();
    }catch(Exception e) {
        e.printStackTrace();
    }


Notes
(0003209)
ferg   
06-18-08 15:55   
server/14g9