当前位置: 首页 > news >正文

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

1 在数据库监听未启动时

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

2 在建立socket连接时

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

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 参数生效,单位 毫秒

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();
}

测试程序如下

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();}}
}

相关文章:

  • BFC理解
  • 60页PDF | 四川电信数据湖 + 数据中台实施方案:覆盖数据能力、数据资产及数据治理的全流程建设指南
  • spring cloud gateway 断言(Predicates)与过滤器(filters)
  • day009-用户管理专题
  • Go语言八股之channel详解
  • 火绒互联网安全软件:自主引擎,精准防御
  • 迈向AI辅助数据分析代码生成的透明性与知识共享
  • Java游戏服务器开发流水账(1)游戏服务器的架构浅析
  • 【C++游戏引擎开发】第32篇:物理引擎(Bullet)—约束系统
  • java基础-数组
  • 【AI论文】
  • oracle 数据库sql 语句处理过程
  • 用 NGINX 打造高性能 FastCGI 加速 `ngx_http_fastcgi_module`
  • RabbitMQ高级特性
  • LeetCode 267:回文排列 II —— Swift 解法全解析
  • lc3341. 到达最后一个房间的最少时间 Ⅰ 算法解析
  • LeetCode20_有效的括号
  • 数据结构与算法-单链表的应用
  • 大数据处理利器:Hadoop 入门指南
  • 如何在Ubuntu上安装NVIDIA显卡驱动?
  • 轿车追尾半挂车致3死1伤,事故调查报告:司机过分依赖巡航系统
  • 鸿蒙概念股强势上涨,鸿蒙电脑本月正式发布,生态链即将补全
  • 新加坡总理黄循财领导人民行动党胜选,外交部回应
  • 新闻1+1丨多地政府食堂开放“舌尖上的服务”,反映出怎样的理念转变?
  • 新闻1+1丨多地政府食堂开放 “舌尖上的服务”,反映出怎样的理念转变?
  • 伊朗港口爆炸事故遇难人数最终确定为57人