diff --git a/constants/constants.js b/constants/constants.js index 44ab6ad..7a75406 100644 --- a/constants/constants.js +++ b/constants/constants.js @@ -13,8 +13,11 @@ const TABLE_TYPE = { const INLINE_COMMENT = '--'; +const PERSENT = '__PERCENT__'; + module.exports = { ERROR_MESSAGE, TABLE_TYPE, INLINE_COMMENT, + PERSENT, }; diff --git a/reverse_engineering/api.js b/reverse_engineering/api.js index 70c0f42..cfa704e 100644 --- a/reverse_engineering/api.js +++ b/reverse_engineering/api.js @@ -101,10 +101,13 @@ const getDbCollectionsNames = async (connectionInfo, appLogger, callback, app) = }); try { + const connection = await connectionHelper.connect({ connectionInfo, logger }); + const dbVersion = await instanceHelper.getDbVersion({ connection }); + logger.info('Db version: ' + dbVersion); + logger.info('Get table and schema names'); logger.info(connectionInfo); - const connection = await connectionHelper.connect({ connectionInfo, logger }); const tableNames = await instanceHelper.getDatabasesWithTableNames({ connection, tableType: TABLE_TYPE.table, diff --git a/shared/Db2Client/build.sh b/shared/Db2Client/build.sh index 963bad6..9fc1709 100644 --- a/shared/Db2Client/build.sh +++ b/shared/Db2Client/build.sh @@ -1,3 +1,3 @@ #!/bin/bash -mvn clean compile assembly:single \ No newline at end of file +mvn clean package diff --git a/shared/Db2Client/pom.xml b/shared/Db2Client/pom.xml index 505f0f3..d595eca 100644 --- a/shared/Db2Client/pom.xml +++ b/shared/Db2Client/pom.xml @@ -18,19 +18,29 @@ - - maven-assembly-plugin - - - - org.db2.App - - - - jar-with-dependencies - - - + + maven-assembly-plugin + 3.7.1 + + + + org.db2.App + + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + + diff --git a/shared/Db2Client/readme.md b/shared/Db2Client/readme.md index 6692cac..bfb3f23 100644 --- a/shared/Db2Client/readme.md +++ b/shared/Db2Client/readme.md @@ -19,13 +19,9 @@ For compiling client Using Maven plugin execute: Lifecycle methods: - `mvn clean` -- `mvn compile` - -Plugins: - -- `mvn assembly:single` +- `mvn package` ### Built artifacts -The built JAR file you can find following by `./target/Db2Client-1.0-jar-with-dependencies.jar` +The built JAR file you can find following by `./target/Db2Client-1.0-jar-with-dependencies.jar`, **NOT `Db2Client-1.0.jar`!!!** For use in Db2 plugin rename this JAR file to `Db2Client.jar` and put to `shared/addons/Db2Client.jar` diff --git a/shared/Db2Client/src/main/java/org/db2/App.java b/shared/Db2Client/src/main/java/org/db2/App.java index 4998419..b08abfc 100644 --- a/shared/Db2Client/src/main/java/org/db2/App.java +++ b/shared/Db2Client/src/main/java/org/db2/App.java @@ -37,6 +37,7 @@ public static void main(String[] args) { JSONObject errorObj = new JSONObject(); errorObj.put("message", e.getMessage()); errorObj.put("stack", e.getStackTrace()); + errorObj.put("query", query); result.put("error", errorObj); } finally { @@ -46,7 +47,7 @@ public static void main(String[] args) { } private static String cleanStringValue(String value) { - return value.replace("<\\$>", "\""); + return value.replace("__PERCENT__", "%"); } private static String findArgument(String[] args, Argument argument) { diff --git a/shared/addons/Db2Client.jar b/shared/addons/Db2Client.jar index 00d7b66..55670cb 100644 Binary files a/shared/addons/Db2Client.jar and b/shared/addons/Db2Client.jar differ diff --git a/shared/helpers/queryHelper.js b/shared/helpers/queryHelper.js index 9c0debc..006b352 100644 --- a/shared/helpers/queryHelper.js +++ b/shared/helpers/queryHelper.js @@ -1,4 +1,4 @@ -const { TABLE_TYPE } = require('../../constants/constants'); +const { TABLE_TYPE, PERSENT } = require('../../constants/constants'); /** * @param {{ query: string }} @@ -11,14 +11,18 @@ const cleanUpQuery = ({ query = '' }) => query.replaceAll(/\s+/g, ' '); * @returns {string} */ const getNonSystemSchemaWhereClause = ({ query, schemaNameKeyword }) => { - const whereClause = ` - WHERE ${schemaNameKeyword} NOT LIKE 'SYS%' - AND ${schemaNameKeyword} NOT LIKE '%SYSCAT%' - AND ${schemaNameKeyword} NOT LIKE '%SYSIBM%' - AND ${schemaNameKeyword} NOT LIKE '%SYSSTAT%' - AND ${schemaNameKeyword} NOT LIKE '%SYSTOOLS%' - AND ${schemaNameKeyword} NOT LIKE '%NULLID%' - AND ${schemaNameKeyword} NOT LIKE '%SQLJ%';`; + // On Windows (cmd.exe), environment variables can be referenced using syntax like %PATH%. + // When a command contains such patterns, cmd.exe automatically replaces them with the corresponding environment variable values. + // To prevent this automatic substitution, a placeholder string (PERSENT) is used here instead, + // which will later be replaced with the % symbol inside the Db2Client Java client. + const whereClause = ` + WHERE ${schemaNameKeyword} NOT LIKE 'SYS${PERSENT}' + AND ${schemaNameKeyword} NOT LIKE '${PERSENT}SYSCAT${PERSENT}' + AND ${schemaNameKeyword} NOT LIKE '${PERSENT}SYSIBM${PERSENT}' + AND ${schemaNameKeyword} NOT LIKE '${PERSENT}SYSSTAT${PERSENT}' + AND ${schemaNameKeyword} NOT LIKE '${PERSENT}SYSTOOLS${PERSENT}' + AND ${schemaNameKeyword} NOT LIKE '${PERSENT}NULLID${PERSENT}' + AND ${schemaNameKeyword} NOT LIKE '${PERSENT}SQLJ${PERSENT}';`; const clause = query.includes('WHERE') ? whereClause.replace('WHERE', 'AND') : whereClause;