Is there a way to set connection timeout for JDBC connections?

Not applicable

I have a Node.js base API proxy which uses "trireme-jdbc" to connect to a MSSQL database. Sometimes, queries take too much time, more than 30 seconds, and I get response "gateway timeout" from Apigee.

Is there a better way, how to handle this gracefully? For example, setting some timeout on the JDBC connection, so it will timeout earlier, that the Apigee timeout. Then it should be possible to catch the error in Node.js and return an error.

0 1 2,593
1 REPLY 1

Not applicable

There's not a reasonable way for us to do this in Java, because once we call the JDBC driver's "connect" method in a thread, that thread is going to keep running until it either succeeds or fails.

Does the MSSQL JDBC driver support time sort of timeout option? Often the driver itself supports various options and if a timeout is one of them, then that'd be the best way to solve this because then the timeout will be properly handled by the Trireme code.