Discussions

General J2EE: why I get deadlock while using executeBatch

  1. why I get deadlock while using executeBatch (3 messages)

    I have set the autocommit mode to false, and commit the connection after execute batch updating. I wonder does ms sqlserver driver 2000 ( realease on
    April 19th,2004 ) support batch updating?
    should I get the latest version (driver 2000 sp3 ).

    here is my code .



    ......
          Connection cnn=dbo.getEngineConnection(false);
          Statement stmt=dbo.getStatement(cnn);
          stmt.addBatch("delete from EngineOrg where id="+id);
            stmt.addBatch("delete from um_user2org where org_id="+id);
    // and more batch
            stmt.executeBatch();
            dbo.Commit(cnn);/// here got the dealock
     
     
     
    -----------------
    public static Connection getEngineConnection(boolean autocommit) {
    Connection connection = null;
    try {
    if (initialcontext == null)
    initialcontext = new InitialContext();
    if (engdatasource == null) {
    engdatasource = (DataSource) initialcontext
    .lookup("java:/WebEngineDataSource");
    if (engdatasource == null)
    engdatasource = (DataSource) initialcontext
    .lookup("java:comp/env/jdbc/webengine");
    }
    connection = engdatasource.getConnection();
    connection.setAutoCommit(false);

    } catch (Exception e) {
    e.printStackTrace();
    }
    return connection;
    }
    --------------
  2. use prepared statements[ Go to top ]

    have you tried using a prepared statements for each sql statement of the same type?
  3. I just commit it ,nothing special....
    I'm using MS SQL server 2000 with sp3,
    but my sqlserver 2000 jdbc driver realeased on April 2002,
    does it support batch updating ?
    help!
    [code]
    public void CloseConnection(Connection connection) {
    try {
    if (connection != null && !connection.isClosed()) {
    try {
    if (!connection.getAutoCommit()) {

    connection.commit();

    }
    } catch (Exception e) {
    connection.rollback();
    } finally {
    connection.close();
    connection = null;
    }
    }
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    [/code]
  4. by the way ,I 'm using JBoss 3.0.6[ Go to top ]

    by the way ,I 'm using JBoss 3.0.6