try reading the Oracle document "How to ensure that JDBC queries are always in sync (Doc ID 559564.1)" They suggest using one of these properties:
for the Thin driver: oracle.net.ns.SQLnetDef.TCP_CONNTIMEOUT_STR for the OCI driver: sqlnet.outbound_connection_timeout
I have not tested myself, so I can not guarantee that it really solves the problem.
source share