节点 oracledb 未检测服务器是否关闭
Node oracledb not detecting if server is shutdown
oracledb.getConnection({
user : "",
password : "",
connectString : ""
},
function(err, connection) {
if (err) {
console.log("Error while trying to connect to DB ", err.message);
callback(err.message);
} else {
//My Logic
}
});
我正在使用上述(伪)代码连接到远程 oracledb。我在 windows 环境中工作。连接字符串有 URL 连接到远程数据库。现在,如果我的 username/password 是 incorrect/null,我就能看到那个错误。但是,如果服务器关闭,则不会进入处理错误的部分。如何捕获服务器关闭错误?
任何线索都会有所帮助。 TIA。
可能正在等待 TCP 超时。您可以使用您的 OS 网络配置,and/or 配置 Oracle Net 层(处理应用程序和数据库之间的通信)。
创建一个文件$TNS_ADMIN/sqlnet.ora
(不要忘记设置TNS_ADMIN
所以它被读取!)然后你可以配置SQLNET.OUTBOUND_CONNECT_TIMEOUT
。
根据您的应用程序可用性要求,您还可以配置各种其他选项,例如 SQLNET.RECV_TIMEOUT
and SQLNET.SEND_TIMEOUT
. There might be other options that are of interest to you. Finally you may want to create a tnsnames.ora
file to configure the DB service setting ('ENABLE=BROKEN
')。
19c Easy Connect Plus 语法对于设置其中一些选项很有用,例如每 5 分钟发送一次 keepalive 探测以检测连接是否仍然有效您可以使用像 'mydbhost.example.com/myservicename?expire_time=5' 这样的连接字符串所以你不需要使用 tnsnames.ora 和 sqlnet.ora 文件来进行一些常见的设置。
oracledb.getConnection({ user : "", password : "", connectString : "" }, function(err, connection) { if (err) { console.log("Error while trying to connect to DB ", err.message); callback(err.message); } else { //My Logic } });
我正在使用上述(伪)代码连接到远程 oracledb。我在 windows 环境中工作。连接字符串有 URL 连接到远程数据库。现在,如果我的 username/password 是 incorrect/null,我就能看到那个错误。但是,如果服务器关闭,则不会进入处理错误的部分。如何捕获服务器关闭错误?
任何线索都会有所帮助。 TIA。
可能正在等待 TCP 超时。您可以使用您的 OS 网络配置,and/or 配置 Oracle Net 层(处理应用程序和数据库之间的通信)。
创建一个文件$TNS_ADMIN/sqlnet.ora
(不要忘记设置TNS_ADMIN
所以它被读取!)然后你可以配置SQLNET.OUTBOUND_CONNECT_TIMEOUT
。
根据您的应用程序可用性要求,您还可以配置各种其他选项,例如 SQLNET.RECV_TIMEOUT
and SQLNET.SEND_TIMEOUT
. There might be other options that are of interest to you. Finally you may want to create a tnsnames.ora
file to configure the DB service setting ('ENABLE=BROKEN
')。
19c Easy Connect Plus 语法对于设置其中一些选项很有用,例如每 5 分钟发送一次 keepalive 探测以检测连接是否仍然有效您可以使用像 'mydbhost.example.com/myservicename?expire_time=5' 这样的连接字符串所以你不需要使用 tnsnames.ora 和 sqlnet.ora 文件来进行一些常见的设置。