CodexBloom - Programming Q&A Platform

Oracle Cloud - scenarios connecting to Autonomous Database using Node.js and oracledb

👀 Views: 2 đŸ’Ŧ Answers: 1 📅 Created: 2025-05-31
oracle-cloud oracledb node.js javascript

I'm trying to figure out Could someone explain I'm currently trying to connect to an Oracle Autonomous Database instance using the `oracledb` package in a Node.js application. I've followed the official Oracle documentation for setting up the database and configuring the connection. However, I'm running into the following behavior when trying to establish the connection: ``` behavior: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor ``` My connection configuration is as follows: ```javascript const oracledb = require('oracledb'); async function connectToDb() { try { const connection = await oracledb.getConnection({ user: 'my_username', password: 'my_password', connectString: 'my_db_high?TNS_ADMIN=/path/to/wallet', }); console.log('Successfully connected to the database!'); } catch (err) { console.behavior('Connection behavior: ', err); } } connectToDb(); ``` I've ensured that the TNS_ADMIN path points to the correct directory where my wallet files are stored, including `cwallet.sso`, `ewallet.p12`, and `tnsnames.ora`. I've also checked the `tnsnames.ora` file and it looks like this: ``` my_db_high = (DESCRIPTION = (ADDRESS = (PROTOCOL = tcps)(HOST = my.database.oraclecloud.com)(PORT = 1522)) (CONNECT_DATA = (SERVICE_NAME = my_db_high) ) ) ``` To troubleshoot, I verified that the wallet and configuration files are accessible and correctly set up. I also tried using the IP address instead of the hostname in the `connectString`, but that didn't help either. Additionally, I ensured that my Oracle Cloud service is up and running, and the database status is shown as "available" in the console. I would appreciate any insights into why I'm working with this scenario. Is there something specific about the service name or connection string that I might have overlooked? Also, are there best practices for setting up the connection parameters that I should consider? Thanks in advance! For reference, this is a production mobile app. How would you solve this? I'm working with Javascript in a Docker container on macOS. Any advice would be much appreciated.