I am using ha-jdbc2.0.15 with MySQL5.1.58. I have a system with three nodes each nodes has a database and Tomcat server running web application. The web application communicate all three database on each nodes. When I power off the second node, the database on third node is deactivated as well due to the error "Can't call commit when autocommit=true". After more investigation, the connection has autoCommit=false before execute commit method. It looks like the ha-jdbc reset that value or recreate new jdbc connection during deactivating another database.
I tried add <property name="relaxAutoCommit">true</property> as a MySQL JDBC connection property in ha-jdbc configuration, however that attribute is still false after the underneath jdbc connection created.
Does anybody has any idea or same issue?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For more information, our ha-jdbc configuration is using driver based database connection with three databases. In Tomcat server.xml file we have a dbcp data source configured, in our application start up we initialized another two BasicDataSource and one of them will be closed after server start up. However I found all the MySQL jdbc properties in ha-jdbc config file are skipped during creating driver based database connections. At line of 102 in net.sf.hajdbc.sql.Driver.java, the properties passed to jdbc driver only have user/password.
Thanks for any help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Paul. I will try 3.0 in next product release. I have another question for you.
In your document, there are two examples of ha-jdbc configuration:
1. the driver based
2. the datasource based
Which one is better stability in general? In our product we chose a little bit different configuration. We have driver based ha-jdbc-clusterID.xml file, then we have tomcat DataSource configured with driverClassName="net.sf.hajdbc.sql.Driver" url="jdbc:ha-jdbc:clusterID". Then in our java code we get connection from DataSource and underneath connection is ha-jdbc connection.
Is there any issue or disadvantage with such configuration? Did you test such configuration? Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There are no stability differences between the 2 types of database configuration you listed. In reality, there are 4 ways one could configure HA-JDBC, depending on the root object to be proxied, i.e. javax.sql.Driver, javax.sql.DataSource, javax.sql.ConnectionPoolDataSource, javax.sql.XADataSource. The latter 2 are less common, and would only be used within the context of an application server's configuration.
Tomcat adds a layer of complexity to this, since it instruments DataSources defined via <Resource type="javax.sql.DataSource"/> with connection pooling. Consequently, this configuration results in a connection pool of HA-JDBC connections, where each connection in the pool is really a connection to each database in your cluster.
Alternatively, you could configure a connection pool per database, and configure HA-JDBC to proxy the DataSource for each pool. To do this, configure the pool directly in your ha-jdbc configuration file per database, using org.apache.commons.dbcp.BasicDataSource, com.mchange.v2.c3p0.ComboPooledDataSource, or similar.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am using ha-jdbc2.0.15 with MySQL5.1.58. I have a system with three nodes each nodes has a database and Tomcat server running web application. The web application communicate all three database on each nodes. When I power off the second node, the database on third node is deactivated as well due to the error "Can't call commit when autocommit=true". After more investigation, the connection has autoCommit=false before execute commit method. It looks like the ha-jdbc reset that value or recreate new jdbc connection during deactivating another database.
I tried add <property name="relaxAutoCommit">true</property> as a MySQL JDBC connection property in ha-jdbc configuration, however that attribute is still false after the underneath jdbc connection created.
Does anybody has any idea or same issue?
For more information, our ha-jdbc configuration is using driver based database connection with three databases. In Tomcat server.xml file we have a dbcp data source configured, in our application start up we initialized another two BasicDataSource and one of them will be closed after server start up. However I found all the MySQL jdbc properties in ha-jdbc config file are skipped during creating driver based database connections. At line of 102 in net.sf.hajdbc.sql.Driver.java, the properties passed to jdbc driver only have user/password.
Thanks for any help.
Please retry this with HA-JDBC 3.0.0. This should work correctly.
Thanks Paul. I will try 3.0 in next product release. I have another question for you.
In your document, there are two examples of ha-jdbc configuration:
1. the driver based
2. the datasource based
Which one is better stability in general? In our product we chose a little bit different configuration. We have driver based ha-jdbc-clusterID.xml file, then we have tomcat DataSource configured with driverClassName="net.sf.hajdbc.sql.Driver" url="jdbc:ha-jdbc:clusterID". Then in our java code we get connection from DataSource and underneath connection is ha-jdbc connection.
Is there any issue or disadvantage with such configuration? Did you test such configuration? Thanks.
There are no stability differences between the 2 types of database configuration you listed. In reality, there are 4 ways one could configure HA-JDBC, depending on the root object to be proxied, i.e. javax.sql.Driver, javax.sql.DataSource, javax.sql.ConnectionPoolDataSource, javax.sql.XADataSource. The latter 2 are less common, and would only be used within the context of an application server's configuration.
Tomcat adds a layer of complexity to this, since it instruments DataSources defined via <Resource type="javax.sql.DataSource"/> with connection pooling. Consequently, this configuration results in a connection pool of HA-JDBC connections, where each connection in the pool is really a connection to each database in your cluster.
Alternatively, you could configure a connection pool per database, and configure HA-JDBC to proxy the DataSource for each pool. To do this, configure the pool directly in your ha-jdbc configuration file per database, using org.apache.commons.dbcp.BasicDataSource, com.mchange.v2.c3p0.ComboPooledDataSource, or similar.