英文:
Oracle SQLDeveloper Command-Line (SQLcl) v19 run Script with Connection Timeout
问题
我正在运行 SQLcl 版本
SQL> version
Oracle SQLDeveloper Command-Line (SQLcl) 版本: 19.1.0.0
以下脚本有效
echo @test/oracle_sql_cl/read_schema.sql | sql -S ${USER}/${PASSWORD}@${TNS_NAME}
需要一个超时参数。
以下是一些尝试但没有成功的示例
echo @test/oracle_sql_cl/read_schema.sql | sql -S -t 5 ${USER}/${PASSWORD}@${TNS_NAME}
上述命令失败。
还更新了 TNS_NAME 变量如下
export TNS_NAME="(DESCRIPTION=(TRANSPORT_CONNECT_TIMEOUT=5)(CONNECT_TIMEOUT=5)(RETRY_COUNT=1)(RETRY_DELAY=1)(ADDRESS_LIST=(ADDRESS=...
但连接仍然重试连接。
任何想法将不胜感激 :~)
解决方案
更新连接字符串以包括
export TNS_NAME="(DESCRIPTION=(TRANSPORT_CONNECT_TIMEOUT=2)...
并修改调用为
echo @test/oracle_sql_cl/read_schema.sql | sql -S ${USER}/${PASSWORD}@${TNS_NAME}
英文:
I am running SQLcl verion
SQL> version
Oracle SQLDeveloper Command-Line (SQLcl) version: 19.1.0.0
The following script works
echo @test/oracle_sql_cl/read_schema.sql | sql -S ${USER}/${PASSWORD}@${TNS_NAME}
A timeout parameter is needed.
Here are some examples tired but without success
echo @test/oracle_sql_cl/read_schema.sql | sql -S -t 5 ${USER}/${PASSWORD}@${TNS_NAME}
The above command fails.
Also updated the TNS_NAME var like so
export TNS_NAME="(DESCRIPTION=(TRANSPORT_CONNECT_TIMEOUT=5)(CONNECT_TIMEOUT=5)(RETRY_COUNT=1)(RETRY_DELAY=1)(ADDRESS_LIST=(ADDRESS=...
But connection still reties the connecion.
Any ideas would be much appreciated :~)
Solution
Update the connection string to include
export TNS_NAME="(DESCRIPTION=(TRANSPORT_CONNECT_TIMEOUT=2)...
And modify the invocation to
echo @test/oracle_sql_cl/read_schema.sql | sql -S ${USER}/${PASSWORD}@${TNS_NAME}
答案1
得分: 1
在您的连接字符串中使用JDBC URL。
将超时设置为10毫秒会失败。
将超时设置为1000毫秒会成功。
SQL> connect system/oracle@jdbc:oracle:thin:@(DESCRIPTION=(TRANSPORT_CONNECT_TIMEOUT=10ms)(ADDRESS_LIST=(ADDRESS=(HOST=server.com)(PORT=2213)(PROTOCOL=tcp)))(CONNECT_DATA=(S
ERVICE_NAME=DB213P)))
USER = system
URL = jdbc:oracle:thin:@(DESCRIPTION=(TRANSPORT_CONNECT_TIMEOUT=10ms)(ADDRESS_LIST=(ADDRESS=(HOST=server.com)(PORT=2213)(PROTOCOL=tcp)))(CONNECT_DATA=(SERVICE_NAME=DB213P)))
Error Message = IO Error: The Network Adapter could not establish the connection (CONNECTION_ID=MES6gto9SkeXW93/WnHZ6A==)
SQL> connect system/oracle@jdbc:oracle:thin:@(DESCRIPTION=(TRANSPORT_CONNECT_TIMEOUT=1000ms)(ADDRESS_LIST=(ADDRESS=(HOST=server.com)(PORT=2213)(PROTOCOL=tcp)))(CONNECT_DATA=
(SERVICE_NAME=DB213P)))
Connected.
SQL>;
此JDBC属性CONNECTION_PROPERTY_THIN_NET_CONNECT_TIMEOUT在此处定义/记录。
英文:
Use a JDBC URL in your connect string.
With timeout set to 10 milliseconds it fails.
With timeout set to 1000 milliseconds it works.
SQL> connect system/oracle@jdbc:oracle:thin:@(DESCRIPTION=(TRANSPORT_CONNECT_TIMEOUT=10ms)(ADDRESS_LIST=(ADDRESS=(HOST=server.com)(PORT=2213)(PROTOCOL=tcp)))(CONNECT_DATA=(S
ERVICE_NAME=DB213P)))
USER = system
URL = jdbc:oracle:thin:@(DESCRIPTION=(TRANSPORT_CONNECT_TIMEOUT=10ms)(ADDRESS_LIST=(ADDRESS=(HOST=server.com)(PORT=2213)(PROTOCOL=tcp)))(CONNECT_DATA=(SERVICE_NAME=DB213P)))
Error Message = IO Error: The Network Adapter could not establish the connection (CONNECTION_ID=MES6gto9SkeXW93/WnHZ6A==)
SQL> connect system/oracle@jdbc:oracle:thin:@(DESCRIPTION=(TRANSPORT_CONNECT_TIMEOUT=1000ms)(ADDRESS_LIST=(ADDRESS=(HOST=server.com)(PORT=2213)(PROTOCOL=tcp)))(CONNECT_DATA=
(SERVICE_NAME=DB213P)))
Connected.
SQL>
This JDBC property CONNECTION_PROPERTY_THIN_NET_CONNECT_TIMEOUT is defined/documented here.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论