gbase8s数据库 tcp连接不同阶段的超时处理

1 在数据库监听未启动时

目标端口未监听,会返回RST(Reset)报文,客户端会立即感知连接失败(无重传机制)。此时延迟主要由网络往返时间(RTT)决定,通常为几毫秒到几百毫秒。

2 在建立socket连接时

LOGINTIMEOUT 参数生效,该参数为socket超时参数,单位毫秒

java 复制代码
Socket var5 = new Socket();
if (var3 > 0) {
    var5.connect(var4, var3);
} else {
    var5.connect(var4);
}

3 客户端的连接检测机制

IFX_SOC_KEEPALIVE 参数生效

在配置后,使用操作系统 net.ipv4.tcp_keepalive_time net.ipv4.tcp_keepalive_intvl net.ipv4.tcp_keepalive_probes 参数进行tcp keepalive 检测

4 数据库端连接监测机制

数据库端无需配置,会按照上述三个参数进行连接检测,若net.ipv4.tcp_keepalive_time 为0 则默认30s

5 执行sql超时或者断网等情况

IFX_SOC_TIMEOUT 参数生效 单位 毫秒

6 登录信息验证超时检测

GBASEDBTCONTIME 参数生效,单位 毫秒

java 复制代码
this.sendConnectionRequest(var1, var2, var3, var4, var5, var6, var7);
if (this.conTime > 0) {
    try {
        int var17;
        if (!this.SSLconnection) {
            var17 = this.asfSocket.getSoTimeout();
            this.asfSocket.setSoTimeout(this.conTime * 1000);
            this.recvConnectionResponse();
            this.asfSocket.setSoTimeout(var17);
        } else {
            var17 = this.asfSSLSocket.getSoTimeout();
            this.asfSSLSocket.setSoTimeout(this.conTime * 1000);
            this.recvConnectionResponse();
            this.asfSSLSocket.setSoTimeout(var17);
        }
    } catch (Exception var15) {
        this.disconnect();
        throw var15;
    }
} else {
    this.recvConnectionResponse();
}

测试程序如下

java 复制代码
import com.gbasedbt.jdbc.IfxSqliConnect;
import java.sql.*;
import java.util.Properties;
public class test {
    static {
        try {
            Class<?> aclass = Class.forName("com.gbasedbt.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    public static void main(String[] args) {
        String sql="select vtime(1) from dual;";
        Properties properties= new Properties();
        properties.setProperty("DATABASE","xms");
        properties.setProperty("GBASEDBTSERVER","gbase171");
        properties.setProperty("CONNECTIONCLASS","com.gbasedbt.jdbc.IfxSqliConnect");
        properties.setProperty("PROTOCOLCLASS","com.gbasedbt.jdbc.IfxSqli");
        properties.setProperty("USER","gbasedbt");
        properties.setProperty("DB_LOCALE","zh_CN.utf8");
        properties.setProperty("USERURL","jdbc:gbasedbt-sqli://172.16.39.171:9099/xms:GBASEDBTSERVER=gbase171;DB_LOCALE=zh_CN.utf8;IFX_SOC_TIMEOUT=3000000;");
        properties.setProperty("PASSWORD","Ootr123!");
        properties.setProperty("LOGINTIMEOUT","500000");
        properties.setProperty("IFX_SOC_TIMEOUT","300000");
        properties.setProperty("GBASEDBTCONTIME","200000");
        //properties.setProperty("PROTOCOLTRACEFILE","/home/gbasedbt/xx.log");
        //properties.setProperty("PROTOCOLTRACE","5");
        IfxSqliConnect connection= null;
        long currentTimeMillis = System.currentTimeMillis();
        System.out.println("建立连接时间"+currentTimeMillis);
        try {
            connection = new IfxSqliConnect("gbasedbt","Ootr123!","172.16.39.171:9099",properties);
            if(connection!=null){
                System.out.println("连接成功");
            }
            PreparedStatement statement= connection.prepareStatement(sql);
            statement.executeQuery();
            statement.close();
            connection.close();
            long currentTimeMillis1 = System.currentTimeMillis();
            System.out.println("执行sql成功耗时"+(currentTimeMillis1-currentTimeMillis));
        } catch (SQLException e) {
            long currentTimeMillis1 = System.currentTimeMillis();
            System.out.println("获取连接失败,耗时"+(currentTimeMillis1-currentTimeMillis));
            e.printStackTrace();
        }
    }
}
相关推荐
chalmers_157 分钟前
服务器启动的时候就一个对外的端口,如何同时连接多个客户端?
运维·服务器·网络
寒山李白10 分钟前
IDEA连接MySQL服务器数据库指南
java·数据库·mysql·intellij-idea·idea·database
亿坊电商3 小时前
PHP后端项目中多环境配置管理:开发、测试、生产的优雅解决方案!
服务器·数据库·php
韩立学长3 小时前
基于Springboot的影视评论网站的设计与实现58py6238(程序、源码、数据库、调试部署方案及开发环境)系统界面展示及获取方式置于文档末尾,可供参考。
数据库·spring boot·后端
未来之窗软件服务4 小时前
未来之窗昭和仙君(四十七)开发商品进销存——东方仙盟筑基期
数据库·进销存·仙盟创梦ide·东方仙盟·昭和仙君·东方仙盟架构
努力搬砖的咸鱼4 小时前
容器之间怎么通信?Docker 网络全解析
网络·docker·云原生·容器
IDOlaoluo5 小时前
TinyRDM 1.2.3 Windows版安装教程(附Redis客户端下载及详细步骤)
数据库·redis·缓存
小光学长5 小时前
基于微信小程序的背单词系统x1o5sz72(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
数据库·微信小程序·小程序
我命由我123456 小时前
Derby - Derby 服务器(Derby 概述、Derby 服务器下载与启动、Derby 连接数据库与创建数据表、Derby 数据库操作)
java·运维·服务器·数据库·后端·java-ee·后端框架
电鱼智能的电小鱼7 小时前
基于电鱼 ARM 工控机的井下AI故障诊断方案——让煤矿远程监控更智能、更精准
网络·arm开发·人工智能·算法·边缘计算