JDBC Wrapper for as400 Databases
npm install dh-400jdbc2DH-400JDBC
===========
JDBC Wrapper for the JT400 driver to connect to an AS400 using JDBC.
Usage
=============
1. Require the module:
```
const jdbc = require('dh-400jdbc');
2. Initialize the connection:
``
// build the config.
let config = {
host: 'String',
libraries:
username:
password:
initialPoolCount:
logger:
};
// initialize the module.
jdbc.initialize(config, (err) => {
// Do Something.
});
`
3. Execute a SQL query:
``
jdbc.executeSqlString('SELECT * FROM TABLENAME', (err, results) => {
// Do Something.
});
`
4. Execute a prepared statement query. Note: parameters is an array of values:
`
jdbc.executePreparedStatement(sql, parameters, (err, results) => {
// Do Something.
});
`
5. Execute an update prepared statement. Note: parameters is an array of values:
`
jdbc.executeUpdatePreparedStatement(sql, parameters, (err, results) => {
// Do Something.
});
`
6. Executing a stored procedure. Note: the parameters array is an array of stored procedure parameter objects.
- You can create the objects in this format:
`
{
type: <'in' or 'out'>,
fieldName:
dataType:
value:
}
`
- Or use the convenience functions:
`
let inputParameter = jdbc.createSPInputParameter(value);
let outputParameter = jdbc.createSPOutputParameter(sqlDataType, fieldName);
`
- Execute the statement:
`
jdbc.executeStoredProcedure(sql, parameters, (err, result) => {
// Do Something.
});
`
- Note: The result object is a key value object where the keys are the output parameter field names.
`
{
`
- Note: If your stored procedure returns 1 or more result sets you can access them through the result objects resultSets property. The resultsSetsProperty is an array of arrays where each array is a single result set:
``
{
outputParam1:
outputParam2:
resultSets: [
[],
[]
]
}