#6 Can't call commit when autocommit=true

closed
None
5
2009-04-14
2009-03-17
No

Hi,

I got an error during insert data into a external MySQl' table.

Error: [com.business.cloudbase.common.CBException: Database access error occured while inserting data in external table: Can't call commit when autocommit=true, com.business.cloudbase.common.CBException: Database access error occured while inserting data in external table: Can't call commit when autocommit=true, at com.business.cloudbase.statement.insert.InsertStmt.insertIntoExternalTable(InsertStmt.java:363), at com.business.cloudbase.statement.insert.InsertStmt.execute(InsertStmt.java:195), at com.business.cloudbase.net.ClientHandler$CommandExecutor.handleSQL(ClientHandler.java:487), at com.business.cloudbase.net.ClientHandler$CommandExecutor.run(ClientHandler.java:163)]

(MySQL 5.0.x, MySQL JDBC Driver 5.1.x)

Before CB send insert statements to RDBMS, CB should set autocommit=false.

Thanks,

Youngwoo

Discussion

  • YoungWoo Kim

    YoungWoo Kim - 2009-03-17

    insertStmt.java:
    .
    .
    private void insertIntoExternalTable( CBManager cbManager,
    Path outputPath, Element cbQuery)
    throws CBException
    {
    numRowsInserted = 0;
    Connection conn = null;
    PreparedStatement pStmt = null;
    DatabaseLink dbLink = cbManager.getDatabaseLink( this.dbLinkName);
    String user = dbLink.getUser( );
    String password = dbLink.getPassword( );
    String connURL = dbLink.getConnectionURL( );
    String driverClassName = dbLink.getJDBCDriverClassName( );
    Properties props = dbLink.getJDBCProperties( );

    try
    {
    Class.forName( driverClassName);

    if( props != null)
    {
    conn = DriverManager.getConnection( connURL, props);
    conn.setAutoCommit(false);
    }
    else if( user != null && password != null)
    {
    conn = DriverManager.getConnection( connURL, user, password);
    conn.setAutoCommit(false);
    }
    else
    {
    conn = DriverManager.getConnection( connURL);
    conn.setAutoCommit(false);
    }
    }
    .
    .

    I add a line "conn.setAutoCommit(false);" after "getConnection" method, and then I rebuild CB.
    The error is fixed.

    I'm not a java developer, so I'm not sure.
    please revise the code.

    Thanks,

    Youngwoo

     
  • Tarandeep Singh

    Tarandeep Singh - 2009-03-17
    • assigned_to: nobody --> tsingh
     
  • Tarandeep Singh

    Tarandeep Singh - 2009-04-14
    • status: open --> closed
     
  • Tarandeep Singh

    Tarandeep Singh - 2009-04-14

    Fixed in version 1.3

     

Log in to post a comment.