Database-js driver for Oracle
database-js-oracle
is a wrapper around the
oracledb package. It is intended to
be used with the database-js
package.
npm install database-js-oracle
const Connection = require('database-js').Connection
(async () => {
let connection, statement, rows
connection = new Connection('oracle://my_secret_username:my_secret_password@MY_ORA_SID')
try {
statement = await connection.prepareStatement("SELECT SYSDATE FROM DUAL")
rows = await statement.query()
console.log(rows)
} catch (error) {
console.log(error)
} finally {
await connection.close()
}
})()
The URI used in the Connection
constructor has the following format:
oracle://[username[:password]@][connectString][?extraKey=extraValue[&extraKey=extraValue...]]
For connectString
, refer to the oracledb
documentation.
Refer to database-js-common
for how extraKey/extraValue
are handled, then refer to the oracledb
documentation
for what extra parameters and values are supported.
TIP: If
connectString
format you need isn't handled correctly in thehostname
slot of the URI, try putting it in as an extraKey. You'll need a placeholder value in the URI.