const oracledb = require('oracledb'); // 设置数据库连接参数 const config = { user: 'system', password: '452131wW', connectString : "192.168.3.29:1521/orcl" // 或者直接使用 'hostname:port/sid' }; async function run() { let connection; try { // 获取数据库连接 connection = await oracledb.getConnection(config); console.log('Connection established.'); // 执行查询 const result = await connection.execute('SELECT * FROM TYPE'); console.log(result.rows); // 输出查询结果 } catch (err) { console.error(err); } finally { if (connection) { // 关闭数据库连接 try { await connection.close(); console.log('Connection closed.'); } catch (err) { console.error(err); } } } }