Knowledge Base > Article [0004]

JDBC connection string for failover

You may have a mirrored SQL database, and it can automatic failover, but it has no VIP (virtual IP). Also you want to run one DualShield server only. How can DualShield benefit from the existing SQL failover feature?

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

Let us look at an example in MySQL. The original JDBC string is in the file server.xml

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

The new string which supports failover,

<Resource name="jdbc/DasDS" driverClassName="com.mysql.jdbc.Driver" maxIdle="2" password="changeit" url="jdbc:mysql://localhost," username="root" maxActive="1000" validationQuery="Select 1" maxWait="5000" type="javax.sql.DataSource">

As you can see, we appended the second server after the original one "localhost" separated with comma. Don't forget to set the failover property:


(its default value was 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"