Subject | Re: socket timeout |
---|---|
Author | hugo.larson |
Post date | 2012-10-30T07:59:38Z |
--- In Firebird-Java@yahoogroups.com, Mark Rotteveel <mark@...> wrote:
Thanks,
Hugo
>OK Mark.
> On 29-10-2012 11:20, Mark Rotteveel wrote:
> > On Mon, 29 Oct 2012 09:20:38 -0000, "hugo.larson" <hugo.larson@...>
> > wrote:
> >> I'm trying to reduce the timeout time when i connect to a database and
> > the
> >> database is down, or the server its on is down.
> >> Right now it take more than 10 seconds for an exception to be thrown
> > which
> >> make my GUI unresponsive.
> >>
> >> Roman suggested:
> >> http://tech.groups.yahoo.com/group/Firebird-Java/message/10603
> >>
> >> But it does not work for me.
> >> I'm using Firebird 1.5.3 with Jbuilder and jaybird 2.1.6
> >
> > The so_timeout specifies the amount of time that a read() call on the
> > socket will block. This is to detect lost connections that weren't
> > explicitly reset or disconnected, or just to limit the amount of time that
> > a read() call will block. See the description on Socket.setSoTimeout()
> > http://docs.oracle.com/javase/7/docs/api/java/net/Socket.html#setSoTimeout(int)
> >
> > The problem you are referring to is the connect timeout, you can't
> > currently control that in Jaybird (maybe there is a standard Java system
> > property for that, but I can't find it right now, I'll see if I can find it
> > tonight).
>
> Unfortunately there is no general Java system property that controls the
> connect timeout. I created a ticket to have Jaybird use a connect
> timeout: http://tracker.firebirdsql.org/browse/JDBC-279
>
> As to a work around to prevent it from blocking your GUI: don't open the
> connection on the GUI thread, but use something that offloads the work
> to a separate thread (eg SwingWorker if you are using Swing, or a
> general Executor(Service) as obtained from
> java.util.concurrent.Executors
> (http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executors.html).
>
> Also: if you also keep so_timeout: make sure it is big enough, because
> if you execute a query that takes very long to prepare or execute, then
> setting it to a too low number could actually result in errors if the
> prepare or execution time is longer than the so_timeout.
>
> Mark
> --
> Mark Rotteveel
>
Thanks,
Hugo