Knowledge Base > Article [0008]

Mirrored SQL server failover JDBC settings

You may already have a mirrored SQL database, and it can be automatic failover, but it has no VIP (virtual IP). You want a single DualShield instance to utilize the mirrored database.

How can DualShield benefit from the existing SQL failover feature?

Well, DualShield Authentication Sever uses JDBC driver to connect to SQL database, you can achieve it by adding the second server into the JDBC connection string.

Let us have a look of an example in server.xml(MySQL as the database server).

<Resource driverClassName="com.mysql.jdbc.Driver" maxActive="1000" maxIdle="2" maxWait="5000" name="jdbc/DasDS" password="changeit" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/dualshield?useUnicode=true& characterEncoding=UTF-8" username="root" validationQuery="Select 1"/>

Now we append the second server after the original one localhost, separated with comma.

<Resource driverClassName="com.mysql.jdbc.Driver" maxActive="1000" maxIdle="2" maxWait="5000" name="jdbc/DasDS" password="changeit" type="javax.sql.DataSource" url="jdbc:mysql://localhost,192.168.124.201:3306/dualshield?useUnicode=true&failOverReadOnly=false&characterEncoding=UTF-8" username="root" validationQuery="Select 1"/>

Don't forget to set the HA property failOverReadOnly=false(its default value = true), otherwise you will get an error "connection is read-only. Queries leading to data modification are not allowed."

MS SQL and ORACE have the similar failover settings in their JDBC connection strings. In MS SQL, it is called "failoverPartner".