To enable JSON functionality, you must configure the DB2® database and the database server.
Before you begin
- Update the PATH system variable for Java™.
- Add the db2jcc.jar file to the CLASSPATH environment
variable or the -cp command-line switch.
- If you do not have a UTF-8 database with a 32 KB page size that
you can use, create one. For example, to create a database jsondb with
automatic storage and territory us, enter the following
command:
db2 create database jsondb automatic storage yes using codeset utf-8 territory us pagesize 32 K
Make
a note of the database server host name, IP address, port number,
and database name. This information is required for client configuration.
- Although not recommended, if you are using a database with less
than 32 K pagesize, manually create a temporary table space with 32
K pagesize. For example, enter the following command:
CREATE BUFFERPOOL NOSQLSYSTOOLSBP ALL DBPARTITIONNUMS SIZE AUTOMATIC PAGESIZE 32K
CREATE TEMPORARY TABLESPACE NOSQLSYSTOOLSTEMP PAGESIZE 32K MANAGED BY AUTOMATIC STORAGE BUFFERPOOL NOSQLSYSTOOLSBP
- Ensure that you have proper authority to create tables and functions
that are required to enable NoSQL JSON functionality. You require
the following privileges:
- CREATETAB authority and CREATE FUNCTION for the SYSTOOLS schema
- DBADM authority for the target database
- Ensure that the dft_table_org database configuration
parameter is set to ROW.
- Ensure that you have the database server host name, IP address,
port number, and database name handy from the server configuration.
Procedure
To configure a DB2 database
for JSON functionality:
- From the sqllib\json\bin folder, start
the NoSQL command-line interface by running one of the following scripts:
- On Windows, use db2nosql.bat
- On Linux and UNIX, use db2nosql.sh
The script defaults to localhost:50000 for the database, unless
you specify otherwise by using the -hostName and -port options.
- On the command line, create the tables and functions for
the database to enable DB2 JSON
capability by typing enable(true).
- To exit the command-line interface, type quit.
Example
The
following sample script shows the commands to enable DB2 JSON:
./db2nosql.sh -user myuser -hostName myhost -port 50000 -db jsondb -password mypasswd
nosql>enable(true)
Database artifacts created successfully
nosql>quit