You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by rabi <ra...@wipro.com> on 2006/12/28 08:07:45 UTC

jdbc auditor for MySQL data source-autocommit

While configuring the jdbc auditor for MySQL data source, I got the following
error
ERROR - JdbcAuditor                    - Could not persist exchange
java.sql.SQLException: Can't call commit when autocommit=true

By default, MySQL starts new connections with autocommit enabled. So all the
calls to connection.commit(); would result in this error, like the way it is
done in jdbcAuditor

   Connection connection = dataSource.getConnection();
            try {
            	store(connection, id, data);
                connection.commit();
            } finally {
                close(connection);
            }

I think it should set the autocommit property to false, if it want to commit
the default transaction and start a new one 

The other possible way is to use explicit transactions. 
-- 
View this message in context: http://www.nabble.com/jdbc-auditor-for-MySQL-data-source-autocommit-tf2889229s12049.html#a8071741
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: jdbc auditor for MySQL data source-autocommit

Posted by Guillaume Nodet <gn...@gmail.com>.
Cool, thanks a lot !
I have just checked in a slightly modified patch, could you
please test it on your configuration ?
See http://svn.apache.org/viewvc?view=rev&revision=490828

On 12/28/06, rabi <ra...@wipro.com> wrote:
>
> Sorry, Did not check the jira before raising the issue.. I have created the
> patch. Also modified DefaultJDBCAdapter class to move setAutoCommit(false)
> in doCreateTables to jdbcAuditor class to make it consistent. Let me know if
> this is good enough. http://www.nabble.com/file/5137/jdbcAuditor-patch.zip
> jdbcAuditor-patch.zip
> --
> View this message in context: http://www.nabble.com/jdbc-auditor-for-MySQL-data-source-autocommit-tf2889229s12049.html#a8078388
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet

Re: jdbc auditor for MySQL data source-autocommit

Posted by rabi <ra...@wipro.com>.
Sorry, Did not check the jira before raising the issue.. I have created the
patch. Also modified DefaultJDBCAdapter class to move setAutoCommit(false)
in doCreateTables to jdbcAuditor class to make it consistent. Let me know if
this is good enough. http://www.nabble.com/file/5137/jdbcAuditor-patch.zip
jdbcAuditor-patch.zip 
-- 
View this message in context: http://www.nabble.com/jdbc-auditor-for-MySQL-data-source-autocommit-tf2889229s12049.html#a8078388
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: jdbc auditor for MySQL data source-autocommit

Posted by Guillaume Nodet <gn...@gmail.com>.
This issue has already been raised,
see http://issues.apache.org/activemq/browse/SM-742
If anybody has time to write a patch and test it, i would
be glad to check it in ...

On 12/28/06, rabi <ra...@wipro.com> wrote:
>
> While configuring the jdbc auditor for MySQL data source, I got the following
> error
> ERROR - JdbcAuditor                    - Could not persist exchange
> java.sql.SQLException: Can't call commit when autocommit=true
>
> By default, MySQL starts new connections with autocommit enabled. So all the
> calls to connection.commit(); would result in this error, like the way it is
> done in jdbcAuditor
>
>    Connection connection = dataSource.getConnection();
>             try {
>                 store(connection, id, data);
>                 connection.commit();
>             } finally {
>                 close(connection);
>             }
>
> I think it should set the autocommit property to false, if it want to commit
> the default transaction and start a new one
>
> The other possible way is to use explicit transactions.
> --
> View this message in context: http://www.nabble.com/jdbc-auditor-for-MySQL-data-source-autocommit-tf2889229s12049.html#a8071741
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet