What should I do if the connection time exceeds 20 seconds and a server disconnection error is returned when executing the SELECT SLEEP(21) FROM DUAL statement?
Set the READTIMEOUT parameter in the odbc.ini configuration file, which triggers the closing of the socket by a socket read timeout and allows the client to actively disconnect from the server to avoid long-time blocking of the client.
# Configure the odbc.ini configuration file
[OBDSN]
Driver = OBDRIVER
Description = OceanBase Driver DSN
SERVER = xxx.xxx.xxx.xxx (Database IP address)
PORT = 38884 (Actual database port number)
USER = tester@oracle (Username for logging in to the database)
Password = 1****** (Password for logging in to the database)
Database = oceanbase (Database name)
OPTION = 4
charset = UTF8 (Database character set)
READTIMEOUT= 20
Note that if READTIMEOUT=20 and ob_query_timeout=10000000 (10s), executing SELECT SLEEP(15) FROM DUAL will return a TIMEOUT error. This approach is achieved by setting ob_query_timeout, which causes the server to actively report an error to the client if the execution time exceeds the specified time, thereby avoiding long-time blocking of the client.