In this sample nodejs app I am trying to connect to oracle database with a wallet. The wallet is created in the server, and, the contents of the wallet directory was zipped and unzipped into my project's root folder (inside a folder called wallet
).
Further included sqlnet.ora
file in the same folder. Its contents are:
WALLET_LOCATION=
(SOURCE=
(METHOD=FILE)
(METHOD_DATA=
(DIRECTORY=D:codejsmyoracledb-appwallet)
)
)
The main program (index.js
) is pretty straight forward:
const oracledb = require('oracledb');
const path = require('path');
const configDir = path.join(__dirname, 'wallet');
// oracledb.initOracleClient({ configDir: configPath });
// oracledb.initOracleClient();
const poolOptions = {
externalAuth: true,
connectionString: '8.83.87.12:1522/ORCLCDB',
configDir
};
oracledb.createPool(poolOptions, function(err, pool){
if(err) {
console.error(err);
process.exit(1);
}
else {
pool.getConnection(function(err, conn){
if(err) {
console.error(err);
process.exit(2);
}
else {
conn.execute('select sysdate from dual', [], {}, function(err, result){
if(err) {
console.error(err);
process.exit(3);
}
else {
conn.release(function(){
console.log('Result:', JSON.stringify(result));
process.exit(0);
});
}
});
}
});
}
});
I have used oracledb
as the client to connect to my remote database. I get an error in the callback for pool.getConnection()
. This is verified by the error code returned.
The error output to console is:
[Error: ORA-01017: invalid username/password; logon denied] {
errorNum: 1017,
offset: 0
}
I have tried various of trying to initialize the oracledb client (oracledb.initOraClient()
), but, the result is the same. What am I doing wrong here?
Ps: if interested in how the wallet was created read this post and its comments.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…