2 Replies Latest reply on Jun 28, 2010 9:48 AM by Sean Burns

    Using MySQL replication driver with JBoss Transactions

    Sean Burns Newbie

      Hi,

       

      I am trying to use the MySQL replication driver. In order to tell MySQL to use the "read only" servers, I need to set the connection to Read Only. This is quite easy to do as I am using hibernate.

       

      So, I thought for my Select queires I would set the connection to readonly. Do the select, then set it back to normal.

       

       

      ((Session)em.getDelegate()).connection().setReadOnly(true);
      resultList = em.createQuery("SELECT a From EntityObject").getResultList();
      ((Session)em.getDelegate()).connection().setReadOnly(false);
      

       

      This does not work because JBoss then throws a SQL exception that I cannot set ReadOnly on a managed connection.

       

      My Question is then.

       

      What is the best way to use the replication driver of MySql? (Or any Database where there is a master(write)/slaves(read) setup with JBoss)

       

      Thanks.