简体   繁体   English

使用 node.js oracledb 连接到 Oracle DB

[英]Connect to Oracle DB using node.js oracledb

I'm trying to connect to Oracle DB using official node-oracledb driver for Node.js and receive:我正在尝试使用 Node.js 的官方 node-oracledb 驱动程序连接到 Oracle DB 并接收:

ORA-12154: TNS: could not resolve the connect identifier specified. ORA-12154: TNS: 无法解析指定的连接标识符。 var oracledb = require('oracledb'); var oracledb = require('oracledb'); oracledb.getConnection({ user: "", password: "", connectString: "DNS=MY;UID=MYNAME;PWD=MYPWD" }, function(err, connection) {... oracledb.getConnection({ 用户: "", 密码: "", connectString: "DNS=MY;UID=MYNAME;PWD=MYPWD" }, function(err, connection) {...

Same connectString in Excel ( connectString="ODBC;DNS=MY;UID=MYNAME;PWD=MYPWD" ) works fine, as well as tnsping to DB, so it's not about TNS config and enviromental variables. Excel 中的相同 connectString( connectString="ODBC;DNS=MY;UID=MYNAME;PWD=MYPWD" )工作正常,以及 tnsping 到 DB,所以它与 TNS 配置和环境变量无关。

Please note the documentation on connectString .请注意有关 connectString 的文档 You can use the Easy Connect Syntax or the Net Service Names syntax.您可以使用 Easy Connect 语法或网络服务名称语法。 ODBC is not documented as a supported syntax. ODBC 没有记录为受支持的语法。

If you look at your ODBC configuration in Windows (Google if needed), you should be able to identify the server and port (default port is 1521) of the database along with the service name you're using.如果您查看 Windows 中的 ODBC 配置(如果需要,请使用 Google),您应该能够识别数据库的服务器和端口(默认端口为 1521)以及您使用的服务名称。 Once you have those values you should be able to create the connectString using easy connect syntax rather easily.一旦你有了这些值,你应该能够很容易地使用简单的连接语法创建 connectString。

Also, the user and password values should come through their designated parameters, not through the connectString parameter.此外,用户和密码值应该通过它们指定的参数,而不是通过 connectString 参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM