How to connect to JDBC database in APIGEE to execute queries?

Hi,

I have a requirement where when an API request comes to Apigee, it connects to JDBC and executes database queries to save and retrieve the OTP. What is the process to connect to JDBC database and execute query in Apigee?

0 3 819
3 REPLIES 3

Not applicable

Connecting to database from Apigee for querying is not a good idea. You can use one web service to do that for you and Apigee will call to the web service.

Else you can use java callout to connect. But this will make Apigee proxy overloaded.

Hi

I am trying to connect to Oracle DB using Node.js and using code below but it is not working




process.env.ORA_SDTZ = 'UTC'; const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); async function run() { let connection; try { let sql, binds, options, result; connection = await oracledb.getConnection(dbConfig); // // Create a table // const stmts = [ `DROP TABLE no_example`, `CREATE TABLE no_example (id NUMBER, data VARCHAR2(20))` ]; for (const s of stmts) { try { await connection.execute(s); } catch(e) { if (e.errorNum != 942) console.error(e); } } // // Insert three rows // sql = `INSERT INTO no_example VALUES (:1, :2)`; binds = [ [101, "Alpha" ], [102, "Beta" ], [103, "Gamma" ] ]; // For a complete list of options see the documentation. options = { autoCommit: true, // batchErrors: true, // continue processing even if there are data errors bindDefs: [ { type: oracledb.NUMBER }, { type: oracledb.STRING, maxSize: 20 } ] }; result = await connection.executeMany(sql, binds, options); console.log("Number of rows inserted:", result.rowsAffected); // // Query the data // sql = `SELECT * FROM no_example`; binds = {}; // For a complete list of options see the documentation. options = { outFormat: oracledb.OUT_FORMAT_OBJECT, // query result format // extendedMetaData: true, // get extra metadata // prefetchRows: 100, // internal buffer allocation size for tuning // fetchArraySize: 100 // internal buffer allocation size for tuning }; result = await connection.execute(sql, binds, options); console.log("Metadata: "); console.dir(result.metaData, { depth: null }); console.log("Query results: "); console.dir(result.rows, { depth: null }); // // Show the date. The value of ORA_SDTZ affects the output // sql = `SELECT TO_CHAR(CURRENT_DATE, 'DD-Mon-YYYY HH24:MI') AS CD FROM DUAL`; result = await connection.execute(sql, binds, options); console.log("Current date query results: "); console.log(result.rows[0]['CD']); } catch (err) { console.error(err); } finally { if (connection) { try { await connection.close(); } catch (err) { console.error(err); } } } } run();

using Node.js running where, exactly?