0

I would like to find out how I can set a timeout for a Statement.executeBatch() in Java. The code works well when the database is up, but when I block the db IP in iptables, the JVM hangs at executeBatch(). I tried using .setQueryTimeout(10) but an exception is thrown: SQLException cannot be cast to SybSQLException

On database side I use Sybase and jdbc2 for connection Thank you.

PS: I can't post the code because it is company copyrighted.

nucandrei
  • 926
  • 3
  • 13
  • 31
  • Maybe check if db is up before executeBatch() like here: http://stackoverflow.com/questions/4215742/how-to-test-if-jdbc-driver-is-installed-correctly-and-if-the-db-can-be-connected – PeterMmm Jan 31 '14 at 09:51
  • Sybase is a company, not a database. Which Sybase product are you using? – Mike Gardner Jan 31 '14 at 13:28
  • @PeterMmm Hi. Thanks for the answers. I always check if the db is up before, but this is not enough. Maybe the connection is lost when trying to commit! – nucandrei Feb 03 '14 at 09:23
  • @MichaelGardner I don't know the Sybase product. I am on the client side. – nucandrei Feb 03 '14 at 09:24
  • So your code with .setQueryTimeout() compiles fine but you get the Exception (after 10ms(?)) at runtime ? Do you catch a SybSQLException ? – PeterMmm Feb 03 '14 at 09:43
  • For the first question the answer is YES. For the second question the answer is NO, I do not catch a SybSQLException nor SQLException but Class Cast Exception written above in bold. – nucandrei Feb 03 '14 at 12:28

0 Answers0