I have datasource configuration file where i have context
with resource(s)
like this
<Context>
<Resource
name="jdbc/pds"
auth="Container"
driverClassName="oracle.jdbc.driver.OracleDriver"
factory="myPackage.EncryptedDataSourceFactory"
logAbandoned="true"
maxTotal="30"
maxIdle="10"
maxWaitMillis="1000"
password="encryptedPassword"
removeAbandoned="true"
removeAbandonedTimeout="60"
type="javax.sql.DataSource"
url="jdbc:oracle:thin:@myFirstIP:port:MYDB"
username="username"
accessToUnderlyingConnectionAllowed="true"
validationQuery="select 1 from dual" />
</Context>
My goal is to take data from base with the ip myFirstIP
but if can not execute validationQuery
with some reason , for example base is disabled, I want to take connect and take data from base with ip mySecondIP
.
I know that i can create second resource which has mySecondIP
ip and check it on application side (in JAVA for me) if myFirstIP
is disabled create connection with mySecondIP
. But if I don't want additional checks on application side , can i make it using this configuration file to make default connection with myFirstIP
and if it is disabled with mySecondIP
?Is it possible ? If it is not possible what is best solution for my problem ?
I am using oracle 11.2.0.2.0
, java8
and tomcat 8.5 / wildfly 9