JSON command-line interface (CLI)
Use the command-line interface (CLI) to interact dynamically with the JSON collections and harness the capability of NoSQL. The CLI requires a Java™ runtime environment (JRE) of Version 1.5 or later.
Tip: The Java API is no longer the recommended approach for working with JSON data in Db2 for z/OS®. For best results, use SQL and the built-in functions that are supplied with Db2 for z/OS instead. For more information, see Working with JSON documents by using SQL.
There are three ways to interact with the command line:
- Start an interactive shell by specifying the URL, user ID, and password.The following is a sample command to start the interactive shell:
java -cp nosqljson.jar;db2jcc4.jar;license-jar-file-name; js.jar com.ibm.nosql.json.cmd.NoSqlCmdLine --url jdbc:db2://localhost:50000/jsondb --user tonysun --password **** - Run a .js file. The command line runs the .js file
instead of through a shell. The application ends after all the commands are completed.The following is a sample command to run a JavaScript file:
java -cp nosqljson.jar;db2jcc4.jar;license-jar-file-name; js.jar com.ibm.nosql.json.cmd.NoSqlCmdLine --url jdbc:db2://localhost:50000/jsondb; --user tonysun --password **** --file "file.js" - Evaluate a command, by using the eval command. The command line runs a one
line command, and then the applications ends. The following is a sample command:
java -cp nosqljson.jar;license-jar-file-name; js.jar com.ibm.nosql.json.cmd.NoSqlCmdLine --url jdbc:db2://localhost:50000/jsondb; --user tonysun --password **** --eval "db.things.find()"