You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Wayne1285 <Wa...@hotmail.com> on 2006/03/30 06:55:13 UTC
MySQL Persistence fails on autocommit.
I am using ActiveMQ-4.0-RC1 with a MySQL database v5 for persistence. When
it opens the connection, it dies because the autocommit was not turned off
before doing commits. Is there a way I can turn autocomits off, or is this
something that ActiveMq should have as default behavior for MySql databases?
Here is the code
========================================
m_jmsBroker = new BrokerService();
m_jmsBroker.setUseJmx(true);
Class.forName("com.mysql.jdbc.Driver").newInstance();
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setDatabaseName("jmsdb");
dataSource.setUser("xxxxx");
dataSource.setPassword("xxxxxxxxxx");
dataSource.setPort(6033);
JDBCPersistenceAdapter persistor = new JDBCPersistenceAdapter();
persistor.setDataSource(dataSource);
m_jmsBroker.setPersistent(true);
m_jmsBroker.setPersistenceAdapter(persistor);
m_jmsBroker.addConnector("tcp://localhost:61616");
m_jmsBroker.start();
==========================================
Here is the log
==========================================
INFO JmsBrokerManager.start() Using dataSource jdbc:mysql://:6033/jmsdb
-- 10:39:10.125
INFO ActiveMQ 4.0-RC1 JMS Message Broker (SegOneJmsBroker) is starting --
10:39:10.359
INFO For help or more information please see: http://www.logicblaze.com
-- 10:39:10.359
INFO Database driver recognized: [mysql-ab_jdbc_driver] -- 10:39:10.593
DEBUG Error while closing connection: Can't call commit when
autocommit=true -- 10:39:10.593
java.sql.SQLException: Can't call commit when autocommit=true
at com.mysql.jdbc.Connection.commit(Connection.java:2145)
at
org.apache.activemq.store.jdbc.TransactionContext.close(TransactionContext.java:119)
at
org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.createAdapter(JDBCPersistenceAdapter.java:252)
at
org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.getAdapter(JDBCPersistenceAdapter.java:212)
at
org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.start(JDBCPersistenceAdapter.java:138)
at
org.apache.activemq.broker.BrokerService.createRegionBroker(BrokerService.java:902)
at
org.apache.activemq.broker.BrokerService.createBroker(BrokerService.java:863)
at
org.apache.activemq.broker.BrokerService.getBroker(BrokerService.java:443)
at
org.apache.activemq.broker.BrokerService.addConnector(BrokerService.java:136)
at
org.apache.activemq.broker.BrokerService.addConnector(BrokerService.java:126)
...
--
View this message in context: http://www.nabble.com/MySQL-Persistence-fails-on-autocommit.-t1366465.html#a3664079
Sent from the ActiveMQ - User forum at Nabble.com.
Re: MySQL Persistence fails on autocommit.
Posted by James Strachan <ja...@gmail.com>.
We've a little warning about this on the site...
http://incubator.apache.org/activemq/JDBC+Support
James
On 3/30/06, Jonas Lim <jl...@exist.com> wrote:
> Hi,
>
> Try setting the RelaxAutoCommit to true.
>
> ie. dataSource.setRelaxAutoCommit(true);
>
> Regards,
> Jonas
>
> ----- Original Message -----
> From: "Wayne1285" <Wa...@hotmail.com>
> To: <ac...@geronimo.apache.org>
> Sent: Thursday, March 30, 2006 12:55 PM
> Subject: MySQL Persistence fails on autocommit.
>
>
> >
> > I am using ActiveMQ-4.0-RC1 with a MySQL database v5 for persistence.
> > When
> > it opens the connection, it dies because the autocommit was not turned off
> > before doing commits. Is there a way I can turn autocomits off, or is
> > this
> > something that ActiveMq should have as default behavior for MySql
> > databases?
> >
> > Here is the code
> > ========================================
> > m_jmsBroker = new BrokerService();
> > m_jmsBroker.setUseJmx(true);
> >
> > Class.forName("com.mysql.jdbc.Driver").newInstance();
> >
> > MysqlDataSource dataSource = new MysqlDataSource();
> > dataSource.setDatabaseName("jmsdb");
> > dataSource.setUser("xxxxx");
> > dataSource.setPassword("xxxxxxxxxx");
> > dataSource.setPort(6033);
> >
> > JDBCPersistenceAdapter persistor = new
> > JDBCPersistenceAdapter();
> > persistor.setDataSource(dataSource);
> > m_jmsBroker.setPersistent(true);
> > m_jmsBroker.setPersistenceAdapter(persistor);
> > m_jmsBroker.addConnector("tcp://localhost:61616");
> > m_jmsBroker.start();
> > ==========================================
> >
> > Here is the log
> > ==========================================
> > INFO JmsBrokerManager.start() Using dataSource jdbc:mysql://:6033/jmsdb
> > -- 10:39:10.125
> > INFO ActiveMQ 4.0-RC1 JMS Message Broker (SegOneJmsBroker) is
> > starting --
> > 10:39:10.359
> > INFO For help or more information please see: http://www.logicblaze.com
> > -- 10:39:10.359
> > INFO Database driver recognized: [mysql-ab_jdbc_driver] -- 10:39:10.593
> > DEBUG Error while closing connection: Can't call commit when
> > autocommit=true -- 10:39:10.593
> > java.sql.SQLException: Can't call commit when autocommit=true
> > at com.mysql.jdbc.Connection.commit(Connection.java:2145)
> > at
> > org.apache.activemq.store.jdbc.TransactionContext.close(TransactionContext.java:119)
> > at
> > org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.createAdapter(JDBCPersistenceAdapter.java:252)
> > at
> > org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.getAdapter(JDBCPersistenceAdapter.java:212)
> > at
> > org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.start(JDBCPersistenceAdapter.java:138)
> > at
> > org.apache.activemq.broker.BrokerService.createRegionBroker(BrokerService.java:902)
> > at
> > org.apache.activemq.broker.BrokerService.createBroker(BrokerService.java:863)
> > at
> > org.apache.activemq.broker.BrokerService.getBroker(BrokerService.java:443)
> > at
> > org.apache.activemq.broker.BrokerService.addConnector(BrokerService.java:136)
> > at
> > org.apache.activemq.broker.BrokerService.addConnector(BrokerService.java:126)
> > ...
> > --
> > View this message in context:
> > http://www.nabble.com/MySQL-Persistence-fails-on-autocommit.-t1366465.html#a3664079
> > Sent from the ActiveMQ - User forum at Nabble.com.
>
>
--
James
-------
http://radio.weblogs.com/0112098/
Re: MySQL Persistence fails on autocommit.
Posted by Jonas Lim <jl...@exist.com>.
Hi,
Try setting the RelaxAutoCommit to true.
ie. dataSource.setRelaxAutoCommit(true);
Regards,
Jonas
----- Original Message -----
From: "Wayne1285" <Wa...@hotmail.com>
To: <ac...@geronimo.apache.org>
Sent: Thursday, March 30, 2006 12:55 PM
Subject: MySQL Persistence fails on autocommit.
>
> I am using ActiveMQ-4.0-RC1 with a MySQL database v5 for persistence.
> When
> it opens the connection, it dies because the autocommit was not turned off
> before doing commits. Is there a way I can turn autocomits off, or is
> this
> something that ActiveMq should have as default behavior for MySql
> databases?
>
> Here is the code
> ========================================
> m_jmsBroker = new BrokerService();
> m_jmsBroker.setUseJmx(true);
>
> Class.forName("com.mysql.jdbc.Driver").newInstance();
>
> MysqlDataSource dataSource = new MysqlDataSource();
> dataSource.setDatabaseName("jmsdb");
> dataSource.setUser("xxxxx");
> dataSource.setPassword("xxxxxxxxxx");
> dataSource.setPort(6033);
>
> JDBCPersistenceAdapter persistor = new
> JDBCPersistenceAdapter();
> persistor.setDataSource(dataSource);
> m_jmsBroker.setPersistent(true);
> m_jmsBroker.setPersistenceAdapter(persistor);
> m_jmsBroker.addConnector("tcp://localhost:61616");
> m_jmsBroker.start();
> ==========================================
>
> Here is the log
> ==========================================
> INFO JmsBrokerManager.start() Using dataSource jdbc:mysql://:6033/jmsdb
> -- 10:39:10.125
> INFO ActiveMQ 4.0-RC1 JMS Message Broker (SegOneJmsBroker) is
> starting --
> 10:39:10.359
> INFO For help or more information please see: http://www.logicblaze.com
> -- 10:39:10.359
> INFO Database driver recognized: [mysql-ab_jdbc_driver] -- 10:39:10.593
> DEBUG Error while closing connection: Can't call commit when
> autocommit=true -- 10:39:10.593
> java.sql.SQLException: Can't call commit when autocommit=true
> at com.mysql.jdbc.Connection.commit(Connection.java:2145)
> at
> org.apache.activemq.store.jdbc.TransactionContext.close(TransactionContext.java:119)
> at
> org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.createAdapter(JDBCPersistenceAdapter.java:252)
> at
> org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.getAdapter(JDBCPersistenceAdapter.java:212)
> at
> org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.start(JDBCPersistenceAdapter.java:138)
> at
> org.apache.activemq.broker.BrokerService.createRegionBroker(BrokerService.java:902)
> at
> org.apache.activemq.broker.BrokerService.createBroker(BrokerService.java:863)
> at
> org.apache.activemq.broker.BrokerService.getBroker(BrokerService.java:443)
> at
> org.apache.activemq.broker.BrokerService.addConnector(BrokerService.java:136)
> at
> org.apache.activemq.broker.BrokerService.addConnector(BrokerService.java:126)
> ...
> --
> View this message in context:
> http://www.nabble.com/MySQL-Persistence-fails-on-autocommit.-t1366465.html#a3664079
> Sent from the ActiveMQ - User forum at Nabble.com.