I want to connect tomcat with mysql in a load balanced way.
Is this possible in Tomcat 7?
What changes are required in the following configuration?.
<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="javauser" password="javadude" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/javatest"/>
i have 2 mysql servers localhost:3306 & secondhost:3306
Thanks
MySQL manual for Connector/J indicates it's possible.
Note that you need to configure your MySQL servers to replicate with each other (master-master replication). You should use at least MySQL version 5.6, as it has greatly improved replication reliability. It is however still possible that your application will try to read a data row only written recently to one host which is not yet replicated to the other one, especially when under heavy load.
You may get better results with a proper database clustering solution. Have you considered XtraDB Cluster?