Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Install from npm using:
npm install db2pool --save
In addition, to use this, you will need to create a /credentials/ folder in the base of your project. It will contain the necessary credentials to connect to a db2 database. for example:
{
"database": "dbname",
"hostname": "db2.server.hostname.com",
"username": "<userid>",
"password": "<password>",
"port": 50100,
"protocol": "TCPIP",
"security": "SSL",
"sslCert": "your ssl cert.pem",
"maxPoolSize": size,
"other": ""
}
Also, the package expects the global variable __basedir
to be defined to contain the base path of your project.
Alternatively, the necessary credentials to connect to db2 databases can be stored as a JSON string in the environment variable DBPOOL. for example:
#!/bin/bash
DBPOOL='
{
"dbname": {
"database": "dbname",
"hostname": "db2.server.hostname.com",
"username": "<userid>",
"password": "<password>",
"port": 50100,
"protocol": "TCPIP",
"security": "SSL",
"sslCert": "your ssl cert.pem",
"maxPoolSize": size,
"other": ""
},
"dbname": {
"database": "dbname",
"hostname": "db2.server.hostname.com",
"username": "<userid>",
"password": "<password>",
"port": 50100,
"protocol": "TCPIP",
"security": "SSL",
"sslCert": "your ssl cert.pem",
"maxPoolSize": size,
"other": ""
}
}
'
export DBPOOL
This connection pool makes use of the ibm_db
framework which utilizes the IBM DB2 ODBC driver under the covers. While ODBC may not be the db connectivity method of choice, it is fully functional and works. This is coded in such a fashion that if IBM releases an official DB2 driver for Node.js in the future, it would be relatively easy to swap in to replace the ibm_db
framework.
Instatiate your pool as follows:
const pool = require('db2pool');
pool.getConnection(dbname)
.then((connection) => {
//use connection to access the db
})
.catch((failure) -> {
console.log(failure);
})
returns - ES6 Promise that resolves to a connection object or an error
pool.query(connection, "SELECT * FROM DB WHERE ABC = ?", ["value'"])
.then((result) => {
// do something with the query result
})
.catch((failure) => {
console.log(failure);
})
connection = connection obtained earlier from getConnection
query string = SQL query to run on DB2
query parameters = values that will be substituted by the the driver into the query ?'s
returns - ES6 Promise that resolves to the results of a query or and error
FAQs
Basic connection pool wrapper for ibm db2 node.js driver.
The npm package db2pool receives a total of 13 weekly downloads. As such, db2pool popularity was classified as not popular.
We found that db2pool demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.