0

I want to set jdbc connection lifetime and lifespan how do i do it.

I tried using properties.

Properties info = new properties();
info.put(user,"username");
info.put(password,"password");
info.put(connection lifetime, 0);


DriverManager.getConnection(server,info)

But this didn't work please help.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Rahul Singh
  • 19,030
  • 11
  • 64
  • 86

1 Answers1

0

Try this:

info.setProperty(OracleConnection.CONNECTION_PROPERTY_THIN_NET_CONNECT_TIMEOUT, "2000");

Reference: Setting Network Timeout for JDBC connection

Note that not all JDBC JARs support setting a timeout this way. Sometimes you have to do it programatically.

Community
  • 1
  • 1
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360