Ubuntu下 数据库超时处理

网址 http://manpages.ubuntu.com/manpages/natty/man5/freetds.conf.5.html


natty (5) freetds.conf.5.gz

Provided by: freetds-common_0.82-7_all bug

NAME
     freetds.conf — configuration file for FreeTDS

SYNOPSIS
     The freetds.conf file describes Sybase and Microsoft dataservers to the
     FreeTDS library.  It comprises sections headed by a servername, followed
     by a list of connection properties denoted as name-value pairs.  Defaults
     are defined via a [global] section.  This file supersedes the interfaces
     file that Sybase defines for the same purpose, although the latter is
     still supported.

DESCRIPTION
     A section begins with a servername — the name of the server — in square
     brackets. The servername is chosen at the client's descretion.  (One
     exception: with Sybase ASA the servername must match the database name to
     be used.)

     Sections contain properties, one per line, in the form

           name = value

     where name is the connection property to be described.  Servernames and
     properties are not case sensitive.  Values are case-preserving i.e.,
     copied literally.  Comments begin with either a semicolon (‘;’) or pound
     sign (‘#’) and continue to end of line.  Blank lines are ignored.
     Whitespace surrounding the ‘=’ is ignored.

PROPERTIES
     client charset         encoding of client data; overrides locale(1)
                            settings
                            Domain:   iconv character set names
                            Default:  ISO-8859-1
     connect timeout        seconds to wait for response from connect request
                            Domain:   0 to MAX_INT
                            Default:  none
     debug flags            logging granularity
                            Domain:   32-bit integer
                            Default:  0x4fff
     dump file              specifies location of a logfile and turns on
                            logging
                            Domain:   valid file name
                            Default:  none
     dump file append       log data appended to file instead of re-writing
                            for each connection
                            Domain:   yes/no
                            Default:  no
     emulate little endian  forces big endian machines to act as little endian
                            to communicate with Microsoft Servers
                            Domain:   yes/no
                            Default:  no
     encryption
                            off         disables encryption (default)
                            request     use if available
                            required    allow encrypted connections only
     host                   Name of the host the dataserver is running on.
                            Domain:   host name or IP address
                            Default:  SYBASE
     initial block size     maximum size of a protocol block
                            Domain:   multiple of 512
                            Default:  512
     instance               name of Microsoft SQL Server instance to connect
                            to (supersedes port)
                            Domain:   instance name
                            Default:  none
     port                   port number that the dataserver is listening to
                            Domain:   any valid port
                            Default:  TDS 5.0, 5000; TDS 7.0 and up, 1433
     tds version            TDS protocol version to use
                            Domain:   4.2, 5.0, 7.0, 8.0
                            Default:  --with-tdsver value (5.0 if unspecified)
     text size              default value of TEXTSIZE, in bytes
                            Domain:   0 to 4,294,967,295
                            Default:  4,294,967,295
     timeout                seconds to wait for response to a query
                            Domain:   0 to MAX_INT
                            Default:  none (wait forever)

     Boolean property values may be denoted as on/off, true/false, or 1/0.

   DEBUG FLAGS
     The log's granularity can be controlled with the debug flags property.

           Value     Meaning
             0x02    severe error
             0x04    error
             0x08    warning
             0x10    network
             0x20    information level 1
             0x40    information level 2
             0x80    function trace and info
           0x1000    show pid
           0x2000    show time
           0x4000    show source level info (source file and line)
           0x8000    thread id (not implemented).

NAMES AND LOCATIONS
     The file is normally named /etc/freetds.conf or ${HOME}/.freetds.conf.
     That name can be overridden with the FREETDSCONF environment variable.

     FreeTDS will search conf files for a servername in the following order:
           1.   a filename set programatically via dbsetifile() that is in
                .conf format
           2.   a filename in the environment variable FREETDSCONF that is in
                .conf format
           3.   ${HOME}/.freetds.conf if extant
           4.   @sysconfdir@/freetds.conf

     The search stops with the first file containing the servername.

     If no conf file is found, FreeTDS searches for an interfaces file in the
     following order:
           1.   a filename set programatically via dbsetifile() that is in
                interfaces format
           2.   ${HOME}/.interfaces
           3.   $SYBASE/interfaces (where $SYBASE is an environment variable)

     If the requested servername is not found in any configuration file, the
     fallback mechanism is:
           1.   attempt to convert the name to an IP address with
                inet_addr(3), else
           2.   attempt to convert the name to an IP address with
                gethostbyname(3), else
           3.   attempt to look up the literal name “SYBASE”

ENVIRONMENT
     FREETDSCONF    overrides name and location of the system-wide conf file
     TDSDUMP        overrides the name and location of the FreeTDS log file
     TDSDUMPCONFIG  specifies a name and location of a file that logs the
                    search of configuration files
     TDSHOST        overrides the host property
     TDSPORT        overrides the port property
     TDSQUERY       synonym for DSQUERY, the default servername
     TDSVER         overrides the version specified in the freetds.conf

     The environment variables TDSVER, TDSDUMP, TDSPORT, TDSQUERY, and TDSHOST
     override values set by a .conf or interfaces file.

FILES
     @sysconfdir@/freetds.conf, ${HOME}/.freetds.conf

SEE ALSO
     FreeTDS User Guide.

HISTORY
[FreeTDS] [@version@]          December 23, 2007         [FreeTDS] [@version@]

Ubuntu下数据库访问超时和登录超时一直都是困扰程序员的一件事,今天在翻阅国外文档时,无意发现了上述文章,在此做笔记。
实现登录超时  setConnectOption(QSL_ATTR_CONNECTION_TIMEOUT=1)
实现访问超时  freetds中配置文件 修改timeout = 1, connect timeout = 1即可(记住必须在对应的数据库下添加,直接修改公共的无效)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值