Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

In JBoss data source how can I give multiple connection strings for database fail over in which I want .

There will be two Mysql db with same tables say DB1 and DB2. I want to insert data to DB1, if DB1 is down, then I need to insert it into DB2. During inserting into DB2 if the DB1 comes up I need to insert rest of the data into DB1. How can I configure this in my JBoss?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
194 views
Welcome To Ask or Share your Answers For Others

1 Answer

Follow this documentation. Jboss has configuration setting. https://community.jboss.org/wiki/JBossJCADatabaseFailover

Additionally, if you are NOT using JNDI and plain JDBC call I hav another solution - Say you are making a jdbc call then you will need to get a DB connection, if the DB is down then you will get Database connection exception, in the try catch block, if you encounter connection exception, create a connection in catch block itself for the second database :-)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...