@zowe/db2-for-zowe-cli 6.1.17 → 6.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -10
- package/lib/Db2PluginLifeCycle.d.ts +11 -9
- package/lib/Db2PluginLifeCycle.js +18 -13
- package/lib/Db2PluginLifeCycle.js.map +1 -1
- package/node_modules/axios/CHANGELOG.md +62 -0
- package/node_modules/axios/README.md +233 -5
- package/node_modules/axios/dist/axios.js +387 -89
- package/node_modules/axios/dist/axios.min.js +3 -3
- package/node_modules/axios/dist/axios.min.js.map +1 -1
- package/node_modules/axios/dist/browser/axios.cjs +458 -98
- package/node_modules/axios/dist/esm/axios.js +458 -98
- package/node_modules/axios/dist/esm/axios.min.js +2 -2
- package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
- package/node_modules/axios/dist/node/axios.cjs +568 -116
- package/node_modules/axios/index.d.cts +4 -0
- package/node_modules/axios/index.d.ts +4 -0
- package/node_modules/axios/lib/adapters/fetch.js +64 -11
- package/node_modules/axios/lib/adapters/http.js +134 -50
- package/node_modules/axios/lib/adapters/xhr.js +52 -3
- package/node_modules/axios/lib/core/Axios.js +19 -14
- package/node_modules/axios/lib/core/InterceptorManager.js +107 -8
- package/node_modules/axios/lib/core/buildFullPath.js +1 -13
- package/node_modules/axios/lib/core/dispatchRequest.js +8 -2
- package/node_modules/axios/lib/core/mergeConfig.js +1 -1
- package/node_modules/axios/lib/core/methodList.js +17 -0
- package/node_modules/axios/lib/defaults/index.js +2 -1
- package/node_modules/axios/lib/env/data.js +1 -1
- package/node_modules/axios/lib/helpers/Http2Sessions.js +2 -0
- package/node_modules/axios/lib/helpers/HttpStatusCode.js +11 -1
- package/node_modules/axios/lib/helpers/fromDataURI.js +5 -4
- package/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
- package/node_modules/axios/lib/helpers/progressEventReducer.js +1 -1
- package/node_modules/axios/lib/helpers/resolveConfig.js +4 -2
- package/node_modules/axios/lib/helpers/shouldBypassProxy.js +182 -6
- package/node_modules/axios/lib/helpers/throttle.js +3 -2
- package/node_modules/axios/lib/helpers/toFormData.js +14 -21
- package/node_modules/axios/lib/utils.js +134 -13
- package/node_modules/axios/package.json +1 -1
- package/node_modules/ibm_db/APIDocumentation.md +2883 -2024
- package/node_modules/ibm_db/LICENSE +23 -23
- package/node_modules/ibm_db/README.md +735 -735
- package/node_modules/ibm_db/binding.gyp +99 -98
- package/node_modules/ibm_db/installer/driverInstall.js +984 -958
- package/node_modules/ibm_db/installer/ifx.sh +38 -38
- package/node_modules/ibm_db/installer/setenv.sh +23 -23
- package/node_modules/ibm_db/installer/testODBCConnection.bat +51 -51
- package/node_modules/ibm_db/installer/testODBCConnection.sh +61 -61
- package/node_modules/ibm_db/lib/climacros.js +431 -431
- package/node_modules/ibm_db/lib/odbc.js +4293 -3487
- package/node_modules/ibm_db/lib/simple-queue.js +41 -41
- package/node_modules/ibm_db/package.json +70 -70
- package/node_modules/ibm_db/src/odbc.cpp +1495 -1396
- package/node_modules/ibm_db/src/odbc.h +477 -473
- package/node_modules/ibm_db/src/odbc_connection.cpp +1762 -1612
- package/node_modules/ibm_db/src/odbc_connection.h +228 -215
- package/node_modules/ibm_db/src/odbc_result.cpp +1547 -1547
- package/node_modules/ibm_db/src/odbc_result.h +152 -152
- package/node_modules/ibm_db/src/odbc_statement.cpp +2047 -861
- package/node_modules/ibm_db/src/odbc_statement.h +257 -135
- package/node_modules/ibm_db/src/strptime.c +389 -389
- package/node_modules/ibm_db/src/strptime.h +46 -46
- package/node_modules/ibm_db/test/README +23 -23
- package/node_modules/ibm_db/test/bench-insert.js +62 -62
- package/node_modules/ibm_db/test/bench-insertBatch10.js +74 -74
- package/node_modules/ibm_db/test/bench-insertBatch100.js +75 -75
- package/node_modules/ibm_db/test/bench-insertBatch1000.js +75 -75
- package/node_modules/ibm_db/test/bench-insertBatch10000.js +75 -75
- package/node_modules/ibm_db/test/bench-prepare-bind-execute-closeSync.js +60 -60
- package/node_modules/ibm_db/test/bench-prepare-bind-executeNonQuery.js +53 -53
- package/node_modules/ibm_db/test/bench-prepare-bindSync-execute-closeSync.js +50 -50
- package/node_modules/ibm_db/test/bench-prepare-bindSync-executeNonQuery.js +48 -48
- package/node_modules/ibm_db/test/bench-prepare-execute-closeSync.js +51 -51
- package/node_modules/ibm_db/test/bench-prepare-executeNonQuery.js +47 -47
- package/node_modules/ibm_db/test/bench-prepare-not.js +43 -43
- package/node_modules/ibm_db/test/bench-query-fetch.js +59 -59
- package/node_modules/ibm_db/test/bench-query-fetchAll.js +49 -49
- package/node_modules/ibm_db/test/bench-query-fetchAllSync.js +43 -43
- package/node_modules/ibm_db/test/bench-query.js +40 -40
- package/node_modules/ibm_db/test/bench-querySync-fetchArray.js +28 -28
- package/node_modules/ibm_db/test/bench-querySync.js +29 -29
- package/node_modules/ibm_db/test/common.d.ts +10 -10
- package/node_modules/ibm_db/test/common.js +127 -127
- package/node_modules/ibm_db/test/config.json +7 -7
- package/node_modules/ibm_db/test/config.zos.json +4 -4
- package/node_modules/ibm_db/test/data/sample1.txt +9 -9
- package/node_modules/ibm_db/test/data/trc.fmt +30114 -30114
- package/node_modules/ibm_db/test/nodeEE-leak-huge-query.js +152 -152
- package/node_modules/ibm_db/test/nodeEE-leak-multiple-query-multiple-connections.js +148 -148
- package/node_modules/ibm_db/test/nodeEE-leak-multiple-query-pool-connections.js +154 -154
- package/node_modules/ibm_db/test/nodeEE-leak-multiple-query.js +133 -133
- package/node_modules/ibm_db/test/nodeEE-stress-async-waterfall-multiple-connections.js +174 -174
- package/node_modules/ibm_db/test/nodeEE-stress-async-waterfall.js +169 -169
- package/node_modules/ibm_db/test/nodeEE-stress-mixed-query-multiple-connections.js +159 -159
- package/node_modules/ibm_db/test/nodeEE-stress-mixed-query.js +148 -148
- package/node_modules/ibm_db/test/odbc-bench.c +123 -123
- package/node_modules/ibm_db/test/perfTest.js +53 -53
- package/node_modules/ibm_db/test/quick-example.sh +30 -30
- package/node_modules/ibm_db/test/quick-example.ts +80 -80
- package/node_modules/ibm_db/test/run-bench.js +96 -96
- package/node_modules/ibm_db/test/run-nodeEE.js +132 -132
- package/node_modules/ibm_db/test/run-tests.js +132 -138
- package/node_modules/ibm_db/test/sql-cli.js +28 -28
- package/node_modules/ibm_db/test/test-all-data-types.js +109 -109
- package/node_modules/ibm_db/test/test-array-insert.js +178 -178
- package/node_modules/ibm_db/test/test-async-await.js +105 -105
- package/node_modules/ibm_db/test/test-attributes.js +34 -34
- package/node_modules/ibm_db/test/test-bad-pool-connection-prepare-execute.js +57 -57
- package/node_modules/ibm_db/test/test-basic-test.js +138 -138
- package/node_modules/ibm_db/test/test-binary-array-insert.js +73 -73
- package/node_modules/ibm_db/test/test-blob-from-file.js +90 -90
- package/node_modules/ibm_db/test/test-blob-insert.js +144 -144
- package/node_modules/ibm_db/test/test-blob-stream-insert.js +321 -299
- package/node_modules/ibm_db/test/test-blob-to-file.js +370 -370
- package/node_modules/ibm_db/test/test-block-fetch.js +364 -364
- package/node_modules/ibm_db/test/test-blocking-issue210.js +123 -123
- package/node_modules/ibm_db/test/test-call-async.js +64 -64
- package/node_modules/ibm_db/test/test-call-stmt.js +53 -53
- package/node_modules/ibm_db/test/test-cancel.js +703 -0
- package/node_modules/ibm_db/test/test-chinese-char.js +59 -59
- package/node_modules/ibm_db/test/test-connection.js +306 -0
- package/node_modules/ibm_db/test/test-date.js +32 -32
- package/node_modules/ibm_db/test/test-dbclob.js +93 -93
- package/node_modules/ibm_db/test/test-decimals.js +135 -135
- package/node_modules/ibm_db/test/test-describe-metadata.js +148 -0
- package/node_modules/ibm_db/test/test-executeFile.js +167 -167
- package/node_modules/ibm_db/test/test-executeFileSync.js +85 -85
- package/node_modules/ibm_db/test/test-fetch-apis.js +146 -146
- package/node_modules/ibm_db/test/test-fetchN.js +130 -130
- package/node_modules/ibm_db/test/test-getinfo.js +197 -197
- package/node_modules/ibm_db/test/test-ibm-db-issue14.js +58 -58
- package/node_modules/ibm_db/test/test-ibm-db-issue17.js +54 -54
- package/node_modules/ibm_db/test/test-ibm-db-issue18.js +54 -54
- package/node_modules/ibm_db/test/test-issue-1059-fetchAll-undefined.js +67 -67
- package/node_modules/ibm_db/test/test-issue-1080-array-blob-insert.js +40 -0
- package/node_modules/ibm_db/test/test-issue-54.js +39 -39
- package/node_modules/ibm_db/test/test-issue-get-column-value-2.js +44 -44
- package/node_modules/ibm_db/test/test-issue211.js +80 -80
- package/node_modules/ibm_db/test/test-issue253.js +39 -39
- package/node_modules/ibm_db/test/test-max-pool-size.js +96 -96
- package/node_modules/ibm_db/test/test-memory-leaks-new-objects.js +32 -32
- package/node_modules/ibm_db/test/test-multi-open-query-close.js +75 -75
- package/node_modules/ibm_db/test/test-param-put-data.js +713 -0
- package/node_modules/ibm_db/test/test-pool-idle-connection.js +72 -72
- package/node_modules/ibm_db/test/test-pool-operations.js +325 -0
- package/node_modules/ibm_db/test/test-pool-stale-connections.js +111 -111
- package/node_modules/ibm_db/test/test-pool-uncommited.js +33 -33
- package/node_modules/ibm_db/test/test-prepare-execute.js +339 -0
- package/node_modules/ibm_db/test/test-prepareSync-multiple-execution.js +93 -93
- package/node_modules/ibm_db/test/test-primary-foreign-keys.js +246 -0
- package/node_modules/ibm_db/test/test-procedures.js +243 -0
- package/node_modules/ibm_db/test/test-promise-all-data-types.js +42 -42
- package/node_modules/ibm_db/test/test-query-operations.js +405 -0
- package/node_modules/ibm_db/test/test-quick-example.js +25 -25
- package/node_modules/ibm_db/test/test-row-array-insert.js +167 -167
- package/node_modules/ibm_db/test/test-sp-array.js +54 -54
- package/node_modules/ibm_db/test/test-sp-dbc-6000.js +88 -88
- package/node_modules/ibm_db/test/test-sp-memleak.js +136 -136
- package/node_modules/ibm_db/test/test-sp-resultset-execute.js +269 -269
- package/node_modules/ibm_db/test/test-sp-resultset.js +228 -228
- package/node_modules/ibm_db/test/test-transactions.js +261 -0
- package/node_modules/ibm_db/test/test-typescript.js +48 -48
- package/node_modules/ibm_db/test/test-xml-datatype.js +70 -70
- package/node_modules/ibm_db/test/testWebApp.js +56 -56
- package/node_modules/ibm_db/test/trace +51 -51
- package/node_modules/ibm_db/test/typescript-apis-test.js +978 -978
- package/node_modules/ibm_db/test/webapp.html +17 -17
- package/node_modules/ibm_db/test/webapp.js +79 -79
- package/node_modules/ibm_db/typescript/README.md +28 -28
- package/node_modules/ibm_db/typescript/dist/Database.d.ts +26 -0
- package/node_modules/ibm_db/typescript/dist/ODBCStatement.d.ts +93 -0
- package/package.json +10 -6
- package/node_modules/ibm_db/test/disabled/test-binding-statement-rebinding.js +0 -59
- package/node_modules/ibm_db/test/disabled/test-open-dont-close.js +0 -12
- package/node_modules/ibm_db/test/disabled/test-param-select-with-booleans-only.js +0 -21
- package/node_modules/ibm_db/test/disabled/test-param-select-with-decimals-only.js +0 -20
- package/node_modules/ibm_db/test/disabled/test-param-select-with-null.js +0 -21
- package/node_modules/ibm_db/test/disabled/test-param-select-with-nulls-mixed.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-param-select-with-numbers-mixed.js +0 -22
- package/node_modules/ibm_db/test/disabled/test-param-select-with-numbers-only.js +0 -24
- package/node_modules/ibm_db/test/disabled/test-param-select-with-strings-only.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-param-select-with-unicode.js +0 -15
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-closeSync.js +0 -62
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-error.js +0 -49
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-long-string.js +0 -63
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-executeNonQuery.js +0 -63
- package/node_modules/ibm_db/test/disabled/test-prepare-bindSync-execute-closeSync.js +0 -46
- package/node_modules/ibm_db/test/disabled/test-prepare-bindSync-executeNonQuery.js +0 -50
- package/node_modules/ibm_db/test/disabled/test-prepare.js +0 -34
- package/node_modules/ibm_db/test/disabled/test-prepareSync.js +0 -29
- package/node_modules/ibm_db/test/disabled/test-query-select-fetchAll.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-query-select-fetchAllSync.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-query-select-unicode.js +0 -15
- package/node_modules/ibm_db/test/disabled/test-querySync-select-unicode.js +0 -20
- package/node_modules/ibm_db/test/test-affected-rows.js +0 -55
- package/node_modules/ibm_db/test/test-bad-connection-string.js +0 -30
- package/node_modules/ibm_db/test/test-binding-connection-timeOut.js +0 -31
- package/node_modules/ibm_db/test/test-binding-statement-executeSync.js +0 -84
- package/node_modules/ibm_db/test/test-binding-transaction-commit.js +0 -79
- package/node_modules/ibm_db/test/test-binding-transaction-commitSync.js +0 -53
- package/node_modules/ibm_db/test/test-closed.js +0 -14
- package/node_modules/ibm_db/test/test-connection-object.js +0 -16
- package/node_modules/ibm_db/test/test-describe-column.js +0 -92
- package/node_modules/ibm_db/test/test-describe-database.js +0 -18
- package/node_modules/ibm_db/test/test-describe-table.js +0 -31
- package/node_modules/ibm_db/test/test-domains-open.js +0 -19
- package/node_modules/ibm_db/test/test-global-open-close.js +0 -11
- package/node_modules/ibm_db/test/test-instantiate-one-and-end.js +0 -9
- package/node_modules/ibm_db/test/test-multi-open-close.js +0 -45
- package/node_modules/ibm_db/test/test-multi-openSync-closeSync.js +0 -52
- package/node_modules/ibm_db/test/test-open-close.js +0 -29
- package/node_modules/ibm_db/test/test-open-connectTimeout.js +0 -33
- package/node_modules/ibm_db/test/test-openSync.js +0 -31
- package/node_modules/ibm_db/test/test-pool-close.js +0 -120
- package/node_modules/ibm_db/test/test-pool-connect.js +0 -36
- package/node_modules/ibm_db/test/test-pool-rollbackTransaction.js +0 -35
- package/node_modules/ibm_db/test/test-prepareSync-bad-sql.js +0 -34
- package/node_modules/ibm_db/test/test-promise-open-close.js +0 -33
- package/node_modules/ibm_db/test/test-query-create-table-fetchSync.js +0 -23
- package/node_modules/ibm_db/test/test-query-create-table.js +0 -12
- package/node_modules/ibm_db/test/test-query-drop-table.js +0 -13
- package/node_modules/ibm_db/test/test-query-insert.js +0 -38
- package/node_modules/ibm_db/test/test-query-select-fetch.js +0 -21
- package/node_modules/ibm_db/test/test-query-select-fetchMode-array.js +0 -17
- package/node_modules/ibm_db/test/test-query-select.js +0 -64
- package/node_modules/ibm_db/test/test-queryResult.js +0 -35
- package/node_modules/ibm_db/test/test-queryStream.js +0 -43
- package/node_modules/ibm_db/test/test-querySync-select-with-exception.js +0 -25
- package/node_modules/ibm_db/test/test-querySync-select.js +0 -28
- package/node_modules/ibm_db/test/test-require-and-end.js +0 -8
- package/node_modules/ibm_db/test/test-statement-close.js +0 -118
- package/node_modules/ibm_db/test/test-transaction-commit-sync.js +0 -54
- package/node_modules/ibm_db/test/test-transaction-commit.js +0 -79
|
@@ -1,197 +1,197 @@
|
|
|
1
|
-
var common = require("./common")
|
|
2
|
-
, ibmdb = require("../")
|
|
3
|
-
, assert = require("assert")
|
|
4
|
-
, cn = common.connectionString;
|
|
5
|
-
var platform = require('os').platform();
|
|
6
|
-
|
|
7
|
-
main();
|
|
8
|
-
async function main()
|
|
9
|
-
{
|
|
10
|
-
try {
|
|
11
|
-
const conn = await ibmdb.open(cn);
|
|
12
|
-
await testGetInfoSync(conn);
|
|
13
|
-
await testGetTypeInfoSync(conn);
|
|
14
|
-
await testGetFunctionsSync(conn);
|
|
15
|
-
await testGetFunctionsAwait(conn);
|
|
16
|
-
await testGetInfoAwait(conn);
|
|
17
|
-
await testGetTypeInfoAwait(conn);
|
|
18
|
-
await testGetInfoCallback(conn);
|
|
19
|
-
//testGetTypeInfoCallback(conn);
|
|
20
|
-
} catch (e) {
|
|
21
|
-
console.log(e);
|
|
22
|
-
assert.equal(true, false);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async function testGetInfoSync(conn)
|
|
27
|
-
{
|
|
28
|
-
console.log("\n====== testGetInfoSync ======");
|
|
29
|
-
let dbms = conn.getInfoSync(ibmdb.SQL_DBMS_NAME);
|
|
30
|
-
console.log("SQL_DBMS_NAME(Server Type) = ", dbms);
|
|
31
|
-
console.log("SQL_DBMS_VER(Server Version) = ", conn.getInfoSync(ibmdb.SQL_DBMS_VER));
|
|
32
|
-
console.log("SQL_DRIVER_VER(client version) = ", conn.getInfoSync(ibmdb.SQL_DRIVER_VER));
|
|
33
|
-
console.log("SQL_MAX_SCHEMA_NAME_LEN = ", conn.getInfoSync(ibmdb.SQL_MAX_SCHEMA_NAME_LEN));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async function testGetInfoCallback(conn)
|
|
37
|
-
{
|
|
38
|
-
console.log("\n====== testGetInfoCallback ======");
|
|
39
|
-
conn.getInfo(ibmdb.SQL_DBMS_NAME, function(error, data) {
|
|
40
|
-
if(error) {
|
|
41
|
-
console.log(error);
|
|
42
|
-
} else {
|
|
43
|
-
console.log("SQL_DBMS_NAME(Server Type) = ", data);
|
|
44
|
-
conn.getInfo(ibmdb.SQL_DRIVER_BLDLEVEL, 20, function(error, data) {
|
|
45
|
-
if(error) {
|
|
46
|
-
console.log(error);
|
|
47
|
-
} else {
|
|
48
|
-
console.log("SQL_DRIVER_BLDLEVEL(client level) = ", data);
|
|
49
|
-
conn.getInfo(ibmdb.SQL_MAX_TABLE_NAME_LEN, 30, function(error, data) {
|
|
50
|
-
if(error) {
|
|
51
|
-
console.log(error);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
console.log("SQL_MAX_TABLE_NAME_LEN = ", data);
|
|
55
|
-
conn.getInfo(ibmdb.SQL_DBMS_FUNCTIONLVL, function(err, lvl) {
|
|
56
|
-
if(err) console.log(err);
|
|
57
|
-
else {
|
|
58
|
-
console.log("SQL_DBMS_FUNCTIONLVL(server level) = ", lvl);
|
|
59
|
-
testGetTypeInfoCallback(conn);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async function testGetInfoAwait(conn)
|
|
71
|
-
{
|
|
72
|
-
console.log("\n====== testGetInfoAwait ======");
|
|
73
|
-
try {
|
|
74
|
-
let data = await conn.getInfo(ibmdb.SQL_INVALID_INFO2);
|
|
75
|
-
console.log("SQL_INVALID_INFO = ", data);
|
|
76
|
-
} catch(e) {
|
|
77
|
-
console.log("SQL_INVALID_INFO = ", e);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
try {
|
|
81
|
-
let data = await conn.getInfo(ibmdb.SQL_DBMS_NAME);
|
|
82
|
-
console.log("SQL_DBMS_NAME(Server Type) = ", data);
|
|
83
|
-
console.log("SQL_APPLICATION_CODEPAGE = ",
|
|
84
|
-
await conn.getInfo(ibmdb.SQL_APPLICATION_CODEPAGE));
|
|
85
|
-
conn.getInfo(ibmdb.SQL_APPLICATION_CODEPAGE2)
|
|
86
|
-
.then(data => console.log("SQL_APPLICATION_CODEPAGE2 = ", data))
|
|
87
|
-
.catch(error => console.log("SQL_APPLICATION_CODEPAGE2 = ", error));
|
|
88
|
-
data = await conn.getInfo(ibmdb.SQL_ASYNC_MODE)
|
|
89
|
-
.catch(error => console.log("SQL_ASYNC_MODE = ", error));
|
|
90
|
-
console.log("SQL_DB2_DRIVER_TYPE = ", await conn.getInfo(2567));
|
|
91
|
-
data = await conn.getInfo(ibmdb.SQL_CONNECT_CODEPAGE);
|
|
92
|
-
console.log("SQL_CONNECT_CODEPAGE = ", data);
|
|
93
|
-
} catch (e) {
|
|
94
|
-
console.log(e);
|
|
95
|
-
assert(false);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async function testGetTypeInfoSync(conn)
|
|
100
|
-
{
|
|
101
|
-
console.log("SQL_BIGINT type info = ", conn.getTypeInfoSync(ibmdb.BIGINT));
|
|
102
|
-
//console.log("SQL_ALL_TYPES type info = ", conn.getTypeInfoSync(ibmdb.ALLTYPES));
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
async function testGetTypeInfoAwait(conn)
|
|
106
|
-
{
|
|
107
|
-
console.log("\n====== testGetTypeInfoAwait ======");
|
|
108
|
-
try {
|
|
109
|
-
let data = await conn.getTypeInfo(ibmdb.SQL_INVALID_TYPE);
|
|
110
|
-
console.log("SQL_INVALID_TYPE = ", data);
|
|
111
|
-
} catch(e) {
|
|
112
|
-
console.log("SQL_INVALID_TYPE = ", e);
|
|
113
|
-
}
|
|
114
|
-
console.log("SQL_BLOB type info = ", await conn.getTypeInfo(ibmdb.BLOB));
|
|
115
|
-
|
|
116
|
-
try {
|
|
117
|
-
let data = await conn.getTypeInfo(ibmdb.DBCLOB);
|
|
118
|
-
console.log("SQL_DBCLOB = ", data);
|
|
119
|
-
conn.getTypeInfo(ibmdb.NUMBER)
|
|
120
|
-
.then(data => console.log("NUMBER = ", data))
|
|
121
|
-
.catch(error => console.log("NUMBER = ", error));
|
|
122
|
-
data = await conn.getTypeInfo(ibmdb.STRING)
|
|
123
|
-
.catch(error => console.log("ibmdb.STRING = ", error));
|
|
124
|
-
console.log("SQL_DOUBLE = ", await conn.getTypeInfo(8));
|
|
125
|
-
} catch (e) {
|
|
126
|
-
console.log(e);
|
|
127
|
-
assert(false);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
async function testGetTypeInfoCallback(conn)
|
|
132
|
-
{
|
|
133
|
-
console.log("\n====== testGetTypeInfoCallback ======");
|
|
134
|
-
conn.getTypeInfo(ibmdb.NUMERIC, function(error, data) {
|
|
135
|
-
if(error) { console.log(error); }
|
|
136
|
-
else {
|
|
137
|
-
console.log("SQL_NUMERIC Type Info = ", data);
|
|
138
|
-
conn.getTypeInfo(ibmdb.LONGVARCHAR, function(error, data) {
|
|
139
|
-
if(error) { console.log(error); } else {
|
|
140
|
-
console.log("SQL_LONGVARCHAR Type Info = ", data);
|
|
141
|
-
conn.getTypeInfo(ibmdb.FLOAT, function(error, data) {
|
|
142
|
-
if(error) { console.log(error); }
|
|
143
|
-
else {
|
|
144
|
-
console.log("SQL_FLOAT Type Info = ", data);
|
|
145
|
-
conn.closeSync();
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
async function testGetFunctionsSync(conn)
|
|
155
|
-
{
|
|
156
|
-
console.log("\n====== testGetFunctionsSync ======");
|
|
157
|
-
let fExists = conn.getFunctionsSync(ibmdb.SQLCONNECT);
|
|
158
|
-
console.log("Function SQLConnect Exist = ", fExists);
|
|
159
|
-
console.log("Function SQLFreeConnect Exist = ", conn.getFunctionsSync(ibmdb.SQLFREECONNECT));
|
|
160
|
-
console.log("Function SQLGetFunctions Supported = ", conn.getFunctionsSync(ibmdb.SQLGETFUNCTIONS));
|
|
161
|
-
console.log("Function SQLDrivers supported = ", conn.getFunctionsSync(ibmdb.DRIVERS));
|
|
162
|
-
console.log("Function SQLNumParams supported = ", conn.getFunctionsSync(63));
|
|
163
|
-
console.log("Function Unknows supported = ", conn.getFunctionsSync(630));
|
|
164
|
-
console.log("Function SQLDropDb supported = ", conn.getFunctionsSync(ibmdb.SQLDROPDB));
|
|
165
|
-
console.log("All supported Functions = ", conn.getFunctionsSync(ibmdb.ALLFUNCTIONS));
|
|
166
|
-
console.log("-------------------------------------\n");
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
async function testGetFunctionsAwait(conn)
|
|
170
|
-
{
|
|
171
|
-
console.log("\n====== testGetFunctionsAwait ======");
|
|
172
|
-
try {
|
|
173
|
-
let data = await conn.getFunctions(ibmdb.SQL_INVALID_FUNC);
|
|
174
|
-
console.log("SQL_INVALID_FUNCTION = ", data);
|
|
175
|
-
} catch(e) {
|
|
176
|
-
console.log("SQL_INVALID_FUNCTION = ", e);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
try {
|
|
180
|
-
let data = await conn.getFunctions(ibmdb.SQLCONNECT);
|
|
181
|
-
console.log("ibmdb.SQLCONNECT = ", data);
|
|
182
|
-
console.log("Function SQLGetFunctions Supported = ",
|
|
183
|
-
await conn.getFunctions(ibmdb.SQLGETFUNCTIONS));
|
|
184
|
-
conn.getFunctions(ibmdb.DRIVERS)
|
|
185
|
-
.then(data => console.log("Function DRIVERS supported = ", data))
|
|
186
|
-
.catch(error => console.log("Function DRIVERS supported = ", error));
|
|
187
|
-
data = await conn.getFunctions(63)
|
|
188
|
-
.catch(error => console.log("Function SQLNumParams supported = ", error));
|
|
189
|
-
console.log("SQLDROPDB = ", await conn.getFunctions(ibmdb.SQLDROPDB));
|
|
190
|
-
console.log("All supported Functions = ", await conn.getFunctions(ibmdb.ALLFUNCTIONS));
|
|
191
|
-
} catch (e) {
|
|
192
|
-
console.log(e);
|
|
193
|
-
assert(false);
|
|
194
|
-
}
|
|
195
|
-
console.log("-------------------------------------\n");
|
|
196
|
-
}
|
|
197
|
-
|
|
1
|
+
var common = require("./common")
|
|
2
|
+
, ibmdb = require("../")
|
|
3
|
+
, assert = require("assert")
|
|
4
|
+
, cn = common.connectionString;
|
|
5
|
+
var platform = require('os').platform();
|
|
6
|
+
|
|
7
|
+
main();
|
|
8
|
+
async function main()
|
|
9
|
+
{
|
|
10
|
+
try {
|
|
11
|
+
const conn = await ibmdb.open(cn);
|
|
12
|
+
await testGetInfoSync(conn);
|
|
13
|
+
await testGetTypeInfoSync(conn);
|
|
14
|
+
await testGetFunctionsSync(conn);
|
|
15
|
+
await testGetFunctionsAwait(conn);
|
|
16
|
+
await testGetInfoAwait(conn);
|
|
17
|
+
await testGetTypeInfoAwait(conn);
|
|
18
|
+
await testGetInfoCallback(conn);
|
|
19
|
+
//testGetTypeInfoCallback(conn);
|
|
20
|
+
} catch (e) {
|
|
21
|
+
console.log(e);
|
|
22
|
+
assert.equal(true, false);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function testGetInfoSync(conn)
|
|
27
|
+
{
|
|
28
|
+
console.log("\n====== testGetInfoSync ======");
|
|
29
|
+
let dbms = conn.getInfoSync(ibmdb.SQL_DBMS_NAME);
|
|
30
|
+
console.log("SQL_DBMS_NAME(Server Type) = ", dbms);
|
|
31
|
+
console.log("SQL_DBMS_VER(Server Version) = ", conn.getInfoSync(ibmdb.SQL_DBMS_VER));
|
|
32
|
+
console.log("SQL_DRIVER_VER(client version) = ", conn.getInfoSync(ibmdb.SQL_DRIVER_VER));
|
|
33
|
+
console.log("SQL_MAX_SCHEMA_NAME_LEN = ", conn.getInfoSync(ibmdb.SQL_MAX_SCHEMA_NAME_LEN));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function testGetInfoCallback(conn)
|
|
37
|
+
{
|
|
38
|
+
console.log("\n====== testGetInfoCallback ======");
|
|
39
|
+
conn.getInfo(ibmdb.SQL_DBMS_NAME, function(error, data) {
|
|
40
|
+
if(error) {
|
|
41
|
+
console.log(error);
|
|
42
|
+
} else {
|
|
43
|
+
console.log("SQL_DBMS_NAME(Server Type) = ", data);
|
|
44
|
+
conn.getInfo(ibmdb.SQL_DRIVER_BLDLEVEL, 20, function(error, data) {
|
|
45
|
+
if(error) {
|
|
46
|
+
console.log(error);
|
|
47
|
+
} else {
|
|
48
|
+
console.log("SQL_DRIVER_BLDLEVEL(client level) = ", data);
|
|
49
|
+
conn.getInfo(ibmdb.SQL_MAX_TABLE_NAME_LEN, 30, function(error, data) {
|
|
50
|
+
if(error) {
|
|
51
|
+
console.log(error);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
console.log("SQL_MAX_TABLE_NAME_LEN = ", data);
|
|
55
|
+
conn.getInfo(ibmdb.SQL_DBMS_FUNCTIONLVL, function(err, lvl) {
|
|
56
|
+
if(err) console.log(err);
|
|
57
|
+
else {
|
|
58
|
+
console.log("SQL_DBMS_FUNCTIONLVL(server level) = ", lvl);
|
|
59
|
+
testGetTypeInfoCallback(conn);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function testGetInfoAwait(conn)
|
|
71
|
+
{
|
|
72
|
+
console.log("\n====== testGetInfoAwait ======");
|
|
73
|
+
try {
|
|
74
|
+
let data = await conn.getInfo(ibmdb.SQL_INVALID_INFO2);
|
|
75
|
+
console.log("SQL_INVALID_INFO = ", data);
|
|
76
|
+
} catch(e) {
|
|
77
|
+
console.log("SQL_INVALID_INFO = ", e);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
let data = await conn.getInfo(ibmdb.SQL_DBMS_NAME);
|
|
82
|
+
console.log("SQL_DBMS_NAME(Server Type) = ", data);
|
|
83
|
+
console.log("SQL_APPLICATION_CODEPAGE = ",
|
|
84
|
+
await conn.getInfo(ibmdb.SQL_APPLICATION_CODEPAGE));
|
|
85
|
+
conn.getInfo(ibmdb.SQL_APPLICATION_CODEPAGE2)
|
|
86
|
+
.then(data => console.log("SQL_APPLICATION_CODEPAGE2 = ", data))
|
|
87
|
+
.catch(error => console.log("SQL_APPLICATION_CODEPAGE2 = ", error));
|
|
88
|
+
data = await conn.getInfo(ibmdb.SQL_ASYNC_MODE)
|
|
89
|
+
.catch(error => console.log("SQL_ASYNC_MODE = ", error));
|
|
90
|
+
console.log("SQL_DB2_DRIVER_TYPE = ", await conn.getInfo(2567));
|
|
91
|
+
data = await conn.getInfo(ibmdb.SQL_CONNECT_CODEPAGE);
|
|
92
|
+
console.log("SQL_CONNECT_CODEPAGE = ", data);
|
|
93
|
+
} catch (e) {
|
|
94
|
+
console.log(e);
|
|
95
|
+
assert(false);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function testGetTypeInfoSync(conn)
|
|
100
|
+
{
|
|
101
|
+
console.log("SQL_BIGINT type info = ", conn.getTypeInfoSync(ibmdb.BIGINT));
|
|
102
|
+
//console.log("SQL_ALL_TYPES type info = ", conn.getTypeInfoSync(ibmdb.ALLTYPES));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async function testGetTypeInfoAwait(conn)
|
|
106
|
+
{
|
|
107
|
+
console.log("\n====== testGetTypeInfoAwait ======");
|
|
108
|
+
try {
|
|
109
|
+
let data = await conn.getTypeInfo(ibmdb.SQL_INVALID_TYPE);
|
|
110
|
+
console.log("SQL_INVALID_TYPE = ", data);
|
|
111
|
+
} catch(e) {
|
|
112
|
+
console.log("SQL_INVALID_TYPE = ", e);
|
|
113
|
+
}
|
|
114
|
+
console.log("SQL_BLOB type info = ", await conn.getTypeInfo(ibmdb.BLOB));
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
let data = await conn.getTypeInfo(ibmdb.DBCLOB);
|
|
118
|
+
console.log("SQL_DBCLOB = ", data);
|
|
119
|
+
conn.getTypeInfo(ibmdb.NUMBER)
|
|
120
|
+
.then(data => console.log("NUMBER = ", data))
|
|
121
|
+
.catch(error => console.log("NUMBER = ", error));
|
|
122
|
+
data = await conn.getTypeInfo(ibmdb.STRING)
|
|
123
|
+
.catch(error => console.log("ibmdb.STRING = ", error));
|
|
124
|
+
console.log("SQL_DOUBLE = ", await conn.getTypeInfo(8));
|
|
125
|
+
} catch (e) {
|
|
126
|
+
console.log(e);
|
|
127
|
+
assert(false);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function testGetTypeInfoCallback(conn)
|
|
132
|
+
{
|
|
133
|
+
console.log("\n====== testGetTypeInfoCallback ======");
|
|
134
|
+
conn.getTypeInfo(ibmdb.NUMERIC, function(error, data) {
|
|
135
|
+
if(error) { console.log(error); }
|
|
136
|
+
else {
|
|
137
|
+
console.log("SQL_NUMERIC Type Info = ", data);
|
|
138
|
+
conn.getTypeInfo(ibmdb.LONGVARCHAR, function(error, data) {
|
|
139
|
+
if(error) { console.log(error); } else {
|
|
140
|
+
console.log("SQL_LONGVARCHAR Type Info = ", data);
|
|
141
|
+
conn.getTypeInfo(ibmdb.FLOAT, function(error, data) {
|
|
142
|
+
if(error) { console.log(error); }
|
|
143
|
+
else {
|
|
144
|
+
console.log("SQL_FLOAT Type Info = ", data);
|
|
145
|
+
conn.closeSync();
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async function testGetFunctionsSync(conn)
|
|
155
|
+
{
|
|
156
|
+
console.log("\n====== testGetFunctionsSync ======");
|
|
157
|
+
let fExists = conn.getFunctionsSync(ibmdb.SQLCONNECT);
|
|
158
|
+
console.log("Function SQLConnect Exist = ", fExists);
|
|
159
|
+
console.log("Function SQLFreeConnect Exist = ", conn.getFunctionsSync(ibmdb.SQLFREECONNECT));
|
|
160
|
+
console.log("Function SQLGetFunctions Supported = ", conn.getFunctionsSync(ibmdb.SQLGETFUNCTIONS));
|
|
161
|
+
console.log("Function SQLDrivers supported = ", conn.getFunctionsSync(ibmdb.DRIVERS));
|
|
162
|
+
console.log("Function SQLNumParams supported = ", conn.getFunctionsSync(63));
|
|
163
|
+
console.log("Function Unknows supported = ", conn.getFunctionsSync(630));
|
|
164
|
+
console.log("Function SQLDropDb supported = ", conn.getFunctionsSync(ibmdb.SQLDROPDB));
|
|
165
|
+
console.log("All supported Functions = ", conn.getFunctionsSync(ibmdb.ALLFUNCTIONS));
|
|
166
|
+
console.log("-------------------------------------\n");
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
async function testGetFunctionsAwait(conn)
|
|
170
|
+
{
|
|
171
|
+
console.log("\n====== testGetFunctionsAwait ======");
|
|
172
|
+
try {
|
|
173
|
+
let data = await conn.getFunctions(ibmdb.SQL_INVALID_FUNC);
|
|
174
|
+
console.log("SQL_INVALID_FUNCTION = ", data);
|
|
175
|
+
} catch(e) {
|
|
176
|
+
console.log("SQL_INVALID_FUNCTION = ", e);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
try {
|
|
180
|
+
let data = await conn.getFunctions(ibmdb.SQLCONNECT);
|
|
181
|
+
console.log("ibmdb.SQLCONNECT = ", data);
|
|
182
|
+
console.log("Function SQLGetFunctions Supported = ",
|
|
183
|
+
await conn.getFunctions(ibmdb.SQLGETFUNCTIONS));
|
|
184
|
+
conn.getFunctions(ibmdb.DRIVERS)
|
|
185
|
+
.then(data => console.log("Function DRIVERS supported = ", data))
|
|
186
|
+
.catch(error => console.log("Function DRIVERS supported = ", error));
|
|
187
|
+
data = await conn.getFunctions(63)
|
|
188
|
+
.catch(error => console.log("Function SQLNumParams supported = ", error));
|
|
189
|
+
console.log("SQLDROPDB = ", await conn.getFunctions(ibmdb.SQLDROPDB));
|
|
190
|
+
console.log("All supported Functions = ", await conn.getFunctions(ibmdb.ALLFUNCTIONS));
|
|
191
|
+
} catch (e) {
|
|
192
|
+
console.log(e);
|
|
193
|
+
assert(false);
|
|
194
|
+
}
|
|
195
|
+
console.log("-------------------------------------\n");
|
|
196
|
+
}
|
|
197
|
+
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
/* Test program to access DB2 sample database */
|
|
2
|
-
/*require the ibm_db module*/
|
|
3
|
-
var common = require("./common")
|
|
4
|
-
, assert = require("assert")
|
|
5
|
-
, ibmdb = require("../");
|
|
6
|
-
|
|
7
|
-
var testTable = 'BIGINTTEST';
|
|
8
|
-
var testValues = [10205152031467301, 10205152031467303];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/*Connect to the database server
|
|
12
|
-
param 1: The DSN string which has the details of database name to connect to, user id, password, hostname, portnumber
|
|
13
|
-
param 2: The Callback function to execute when connection attempt to the specified database is completed
|
|
14
|
-
*/
|
|
15
|
-
ibmdb.open(common.connectionString, function(err, conn)
|
|
16
|
-
{
|
|
17
|
-
if(err) {
|
|
18
|
-
console.error("error: ", err.message);
|
|
19
|
-
assert.equal(err.message, null);
|
|
20
|
-
} else {
|
|
21
|
-
|
|
22
|
-
console.log('Connection to DB2 machine successful');
|
|
23
|
-
|
|
24
|
-
try {
|
|
25
|
-
conn.querySync("create table " + testTable + " (COLINT BIGINT)");
|
|
26
|
-
} catch (e) {};
|
|
27
|
-
for(var i=0;i<testValues.length;i++) {
|
|
28
|
-
conn.querySync("insert into " + testTable + " values (" + testValues[i] + ")");
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/*
|
|
32
|
-
On successful connection issue the SQL query by calling the query() function on Database
|
|
33
|
-
param 1: The SQL query to be issued
|
|
34
|
-
param 2: The callback function to execute when the database server responds
|
|
35
|
-
*/
|
|
36
|
-
conn.query("SELECT * FROM " + testTable, function(err, nodetest, moreResultSets) {
|
|
37
|
-
console.log("COLINT\tTESTVALUE");
|
|
38
|
-
console.log("-----------------------------------");
|
|
39
|
-
|
|
40
|
-
for (var i=0;i<nodetest.length;i++)
|
|
41
|
-
{
|
|
42
|
-
console.log(parseInt(nodetest[i].COLINT)+'\t'+testValues[i]);
|
|
43
|
-
if(nodetest[i].COLINT != testValues[i]) {
|
|
44
|
-
//throw error
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
console.log("-----------------------------------");
|
|
48
|
-
conn.querySync("drop table " + testTable);
|
|
49
|
-
/*
|
|
50
|
-
Close the connection to the database
|
|
51
|
-
param 1: The callback function to execute on completion of close function.
|
|
52
|
-
*/
|
|
53
|
-
conn.close(function(){
|
|
54
|
-
console.log("Connection Closed");
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
});
|
|
1
|
+
/* Test program to access DB2 sample database */
|
|
2
|
+
/*require the ibm_db module*/
|
|
3
|
+
var common = require("./common")
|
|
4
|
+
, assert = require("assert")
|
|
5
|
+
, ibmdb = require("../");
|
|
6
|
+
|
|
7
|
+
var testTable = 'BIGINTTEST';
|
|
8
|
+
var testValues = [10205152031467301, 10205152031467303];
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/*Connect to the database server
|
|
12
|
+
param 1: The DSN string which has the details of database name to connect to, user id, password, hostname, portnumber
|
|
13
|
+
param 2: The Callback function to execute when connection attempt to the specified database is completed
|
|
14
|
+
*/
|
|
15
|
+
ibmdb.open(common.connectionString, function(err, conn)
|
|
16
|
+
{
|
|
17
|
+
if(err) {
|
|
18
|
+
console.error("error: ", err.message);
|
|
19
|
+
assert.equal(err.message, null);
|
|
20
|
+
} else {
|
|
21
|
+
|
|
22
|
+
console.log('Connection to DB2 machine successful');
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
conn.querySync("create table " + testTable + " (COLINT BIGINT)");
|
|
26
|
+
} catch (e) {};
|
|
27
|
+
for(var i=0;i<testValues.length;i++) {
|
|
28
|
+
conn.querySync("insert into " + testTable + " values (" + testValues[i] + ")");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
On successful connection issue the SQL query by calling the query() function on Database
|
|
33
|
+
param 1: The SQL query to be issued
|
|
34
|
+
param 2: The callback function to execute when the database server responds
|
|
35
|
+
*/
|
|
36
|
+
conn.query("SELECT * FROM " + testTable, function(err, nodetest, moreResultSets) {
|
|
37
|
+
console.log("COLINT\tTESTVALUE");
|
|
38
|
+
console.log("-----------------------------------");
|
|
39
|
+
|
|
40
|
+
for (var i=0;i<nodetest.length;i++)
|
|
41
|
+
{
|
|
42
|
+
console.log(parseInt(nodetest[i].COLINT)+'\t'+testValues[i]);
|
|
43
|
+
if(nodetest[i].COLINT != testValues[i]) {
|
|
44
|
+
//throw error
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
console.log("-----------------------------------");
|
|
48
|
+
conn.querySync("drop table " + testTable);
|
|
49
|
+
/*
|
|
50
|
+
Close the connection to the database
|
|
51
|
+
param 1: The callback function to execute on completion of close function.
|
|
52
|
+
*/
|
|
53
|
+
conn.close(function(){
|
|
54
|
+
console.log("Connection Closed");
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
/*require the ibm_db module*/
|
|
2
|
-
var common = require("./common")
|
|
3
|
-
, assert = require("assert")
|
|
4
|
-
, ibmdb = require("../");
|
|
5
|
-
|
|
6
|
-
var connString = 'DRIVER={DB2 ODBC Driver};DATABASE=SAMPLE;UID=db2admin;PWD=db2admin;HOSTNAME=localhost;port=50000;PROTOCOL=TCPIP';
|
|
7
|
-
|
|
8
|
-
console.log("Test program to access DB2 sample database");
|
|
9
|
-
var testTable = 'BIGINTTEST';
|
|
10
|
-
var testValues = [10205152031467301, 10205152031467303];
|
|
11
|
-
|
|
12
|
-
/*Connect to the database server
|
|
13
|
-
param 1: The DSN string which has the details of database name to connect to, user id, password, hostname, portnumber
|
|
14
|
-
param 2: The Callback function to execute when connection attempt to the specified database is completed
|
|
15
|
-
*/
|
|
16
|
-
ibmdb.open(common.connectionString, function(err, conn)
|
|
17
|
-
{
|
|
18
|
-
if(err) {
|
|
19
|
-
console.error("error: ", err.message);
|
|
20
|
-
assert.equal(err.message, null);
|
|
21
|
-
} else {
|
|
22
|
-
|
|
23
|
-
console.log('Connection to DB2 machine successful');
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
conn.querySync("create table " + testTable + " (COLINT BIGINT)");
|
|
27
|
-
} catch (e) {}
|
|
28
|
-
for(var i=0;i<testValues.length;i++) {
|
|
29
|
-
conn.querySync("insert into " + testTable + " values (" + testValues[i] + ")");
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/*
|
|
33
|
-
On successful connection issue the SQL query by calling the query() function on Database
|
|
34
|
-
param 1: The SQL query to be issued
|
|
35
|
-
param 2: The callback function to execute when the database server responds
|
|
36
|
-
*/
|
|
37
|
-
conn.query("insert into " + testTable + " values (" + testValues[0] + ")", function(err, nodetest, moreResultSets) {
|
|
38
|
-
|
|
39
|
-
if(err) {
|
|
40
|
-
console.log('Error: '+err);
|
|
41
|
-
process.exit(0);
|
|
42
|
-
}
|
|
43
|
-
conn.querySync("drop table " + testTable);
|
|
44
|
-
|
|
45
|
-
/*
|
|
46
|
-
Close the connection to the database
|
|
47
|
-
param 1: The callback function to execute on completion of close function.
|
|
48
|
-
*/
|
|
49
|
-
conn.close(function(){
|
|
50
|
-
console.log("Connection Closed");
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
});
|
|
1
|
+
/*require the ibm_db module*/
|
|
2
|
+
var common = require("./common")
|
|
3
|
+
, assert = require("assert")
|
|
4
|
+
, ibmdb = require("../");
|
|
5
|
+
|
|
6
|
+
var connString = 'DRIVER={DB2 ODBC Driver};DATABASE=SAMPLE;UID=db2admin;PWD=db2admin;HOSTNAME=localhost;port=50000;PROTOCOL=TCPIP';
|
|
7
|
+
|
|
8
|
+
console.log("Test program to access DB2 sample database");
|
|
9
|
+
var testTable = 'BIGINTTEST';
|
|
10
|
+
var testValues = [10205152031467301, 10205152031467303];
|
|
11
|
+
|
|
12
|
+
/*Connect to the database server
|
|
13
|
+
param 1: The DSN string which has the details of database name to connect to, user id, password, hostname, portnumber
|
|
14
|
+
param 2: The Callback function to execute when connection attempt to the specified database is completed
|
|
15
|
+
*/
|
|
16
|
+
ibmdb.open(common.connectionString, function(err, conn)
|
|
17
|
+
{
|
|
18
|
+
if(err) {
|
|
19
|
+
console.error("error: ", err.message);
|
|
20
|
+
assert.equal(err.message, null);
|
|
21
|
+
} else {
|
|
22
|
+
|
|
23
|
+
console.log('Connection to DB2 machine successful');
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
conn.querySync("create table " + testTable + " (COLINT BIGINT)");
|
|
27
|
+
} catch (e) {}
|
|
28
|
+
for(var i=0;i<testValues.length;i++) {
|
|
29
|
+
conn.querySync("insert into " + testTable + " values (" + testValues[i] + ")");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
On successful connection issue the SQL query by calling the query() function on Database
|
|
34
|
+
param 1: The SQL query to be issued
|
|
35
|
+
param 2: The callback function to execute when the database server responds
|
|
36
|
+
*/
|
|
37
|
+
conn.query("insert into " + testTable + " values (" + testValues[0] + ")", function(err, nodetest, moreResultSets) {
|
|
38
|
+
|
|
39
|
+
if(err) {
|
|
40
|
+
console.log('Error: '+err);
|
|
41
|
+
process.exit(0);
|
|
42
|
+
}
|
|
43
|
+
conn.querySync("drop table " + testTable);
|
|
44
|
+
|
|
45
|
+
/*
|
|
46
|
+
Close the connection to the database
|
|
47
|
+
param 1: The callback function to execute on completion of close function.
|
|
48
|
+
*/
|
|
49
|
+
conn.close(function(){
|
|
50
|
+
console.log("Connection Closed");
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|