Menu

XML configuration

Help
misiek
2012-10-24
2012-10-25
  • misiek

    misiek - 2012-10-24

    Hi,

    I've just started using ha-jdbc 2.1.0-beta-1 driver so as to create mysql cluster. After reading documentation I prepared xml configuration file just like this:

    <ha-jdbc xmlns="urn:ha-jdbc:cluster:2.1">
    <sync id="diff">
    <property name="fetchSize">1000</property>
    <property name="maxBatchSize">100</property>
    </sync>

    <cluster default-sync="diff" balancer="load" meta-data-cache="none"
    dialect="mysql" transaction-mode="parallel"
    auto-activate-schedule="0 * * ? * *" failure-detect-schedule="0 * * ? * *">
        <database id="database1" location="jdbc:mysql://localhost:3306/lportal">
            <user>lportal</user>
            <password>lportal</password>        
        </database>
    </cluster>
    

    </ha-jdbc>

    I got the exception:

    2012-10-25 00:10:47 net.sf.hajdbc.logging.commons.CommonsLogger log
    INFO: Initializing HA-JDBC 2.1.0-beta-1 from C:\Program Files\Java\jdk1.6.0_27\jre\classes\ha-jdbc-cluster1.xml
    java.sql.SQLException: No urlPattern property defined and no embedded database driver was detected on the classpath.
    Cannot connect to database server: No urlPattern property defined and no embedded database driver was detected on the classpath.
    at net.sf.hajdbc.sql.SQLExceptionFactory.createException(SQLExceptionFactory.java:52)
    at net.sf.hajdbc.sql.SQLExceptionFactory.createException(SQLExceptionFactory.java:36)
    at net.sf.hajdbc.sql.AbstractExceptionFactory.createException(AbstractExceptionFactory.java:49)
    at net.sf.hajdbc.util.concurrent.LifecycleRegistry.get(LifecycleRegistry.java:94)
    at net.sf.hajdbc.util.concurrent.LifecycleRegistry.get(LifecycleRegistry.java:33)
    at net.sf.hajdbc.sql.Driver.connect(Driver.java:124)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at org.test.TesterHAJDBC.connectToMySQL(TesterHAJDBC.java:52)
    at org.test.TesterHAJDBC.main(TesterHAJDBC.java:21)
    Caused by: java.lang.IllegalArgumentException: No urlPattern property defined and no embedded database driver was detected on the classpath.
    at net.sf.hajdbc.state.sql.SQLStateManagerFactory.createStateManager(SQLStateManagerFactory.java:108)
    at net.sf.hajdbc.sql.DatabaseClusterImpl.start(DatabaseClusterImpl.java:631)
    at net.sf.hajdbc.util.concurrent.LifecycleRegistry.get(LifecycleRegistry.java:75)
    ... 6 more

    MySQL driver is already in classpath. What am I missing?
    Thanks in advance for help.

     

    Last edit: misiek 2012-10-24
  • Paul Ferraro

    Paul Ferraro - 2012-10-25

    By default, HA-JDBC uses an embedded database to persist its cluster state. This implementation will attempt to use an H2, HSQLDB, or Apache Derby database. If neither of these drivers can be found, it will throw the exception seen above.
    So, you have a few options:

    • Add one these jars to your classpath
    • Use some other JDBC driver, and specify the jdbc url accordingly.
      e.g.

      <state id="sql">
          <property name="urlPattern">jdbc:mydriver:{0}</property>
      </state>
      
    • Or use some other state manager implementation.
      e.g.

      <state id="simple"/>
      
     

    Last edit: Paul Ferraro 2012-10-25

Log in to post a comment.