How to set JDBC connection timeout?

Discussion in 'Java' started by RC, Jul 23, 2003.

  1. RC

    RC Guest

    The Subject says its all.

    I can't do

    DriverManager dm = new DriverManager();

    But I can do

    Connection c = DriverManger.getConnection("jdbc:......", properties);

    My question is how do I use

    DriverManger.setLoginTimeout(10);

    to set the connection time out. If after 10 seconds still not
    able to connect to the database, then time out. throw to
    Exception
    By default if there is something wrong with the database server
    or the host. It may takes 30 seconds to catch in Exception.
    I want to shorter it to only 10 seconds. How do I do that?

    Thank Q very much in advance!
    RC, Jul 23, 2003
    #1
    1. Advertising

  2. RC

    Sudsy Guest

    RC wrote:
    > The Subject says its all.
    >
    > I can't do
    >
    > DriverManager dm = new DriverManager();
    >
    > But I can do
    >
    > Connection c = DriverManger.getConnection("jdbc:......", properties);
    >
    > My question is how do I use
    >
    > DriverManger.setLoginTimeout(10);
    >
    > to set the connection time out. If after 10 seconds still not
    > able to connect to the database, then time out. throw to
    > Exception
    > By default if there is something wrong with the database server
    > or the host. It may takes 30 seconds to catch in Exception.
    > I want to shorter it to only 10 seconds. How do I do that?
    >
    > Thank Q very much in advance!
    >


    DriverManger.setLoginTimeout(10);
    Connection c = DriverManger.getConnection("jdbc:......", properties);
    Sudsy, Jul 23, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guoqi Zheng
    Replies:
    4
    Views:
    13,009
    Guoqi Zheng
    Jun 3, 2004
  2. Keith Wansbrough

    Re: jdbc help:sun.jdbc.odbc.JdbcOdbcDriver

    Keith Wansbrough, Aug 16, 2004, in forum: Java
    Replies:
    0
    Views:
    733
    Keith Wansbrough
    Aug 16, 2004
  3. Betty
    Replies:
    1
    Views:
    9,842
    Juha Laiho
    May 21, 2005
  4. Jesus M. Salvo Jr.
    Replies:
    2
    Views:
    3,999
    robert
    Feb 11, 2006
  5. Mark Probert

    Timeout::timeout and Socket timeout

    Mark Probert, Oct 6, 2004, in forum: Ruby
    Replies:
    1
    Views:
    1,263
    Brian Candler
    Oct 6, 2004
Loading...

Share This Page