#2689 How to set SqlConn timeout?

ahhatem Sun 1 Apr 2018

Hi,

I want to force a lower timeout setting for an Oracle DB connection. How do I set it?

Thanks

SlimerDude Sun 1 Apr 2018

I don't know how exactly, as typically those settings are specific to the DriverManager implementation. See this StackOverflow post for some hints on where to look:

Connection timeout for DriverManager.getConnection()

ahhatem Sun 1 Apr 2018

So, is the only way to do this is to edit:

fantom-1.0.70/src/sql/java/SqlConnImplPeer.java

and add something like:

public static SqlConn openDefault(String uri, String user, String pass)
 {
   try
   {
     SqlConnImpl self = SqlConnImpl.make();
     DriverManager.setLoginTimeout(10);
     self.peer.jconn = DriverManager.getConnection(uri, user, pass);
     self.peer.supportsGetGenKeys = self.peer.jconn.getMetaData().supportsGetGeneratedKeys();
     return self;
   }
   catch (SQLException e)
   {
     throw err(e);
   }
 }

I was hoping I don't have to do this.

SlimerDude Sun 1 Apr 2018

setLoginTimeout() is a static method, so you should be able to something like this:

using java.sql::DriverManager

...
DriverManager.setLoginTimeout(10)
conn := SqlConn.open(...)
...

then you don't need to update the sql pod.

ahhatem Sun 1 Apr 2018

Thanks, seems to work fine using JavaFFI.

Login or Signup to reply.