DB2Jcc verifies that a data server is configured for database access.
To verify the connection, DB2Jcc connects to the specified data server, executes an SQL statement, and executes a java.sql.DatabaseMetadata method.
The user ID under which DB2Jcc runs must have the authority to connect to the specified data server and to execute the specified SQL statement.
>>-java--com.ibm.db2.jcc.DB2Jcc--+-----------+------------------> '- -version-' >--+-----------------+--+--------+------------------------------> '- -configuration-' '- -help-' >--+----------------------------------------------------------------------------------+->< '-url-spec--+---------------------------------------+--+----------+--+-----------+-' '- -user--user-ID-- -password--password-' '-sql-spec-' '- -tracing-'
url-spec:
>>-+----------------------------------------------------+------>< '- -url--+-jdbc:db2://server-+---------+-/database-+-' | '-:--port-' | '-jdbc:db2:database-----------------------'
sql-spec:
.- -sql--'--SELECT * FROM SYSIBM.SYSDUMMY1--'-. >>-+---------------------------------------------+------------->< '- -sql--'--sql-statement--'------------------'
SELECT CURRENT SERVER FROM SYSIBM.SYSDUMMY1;
If the connection is to a DB2 for Linux, UNIX, and Windows server, database is the database name that is defined during installation.
If the connection is to an IBM Informix® data server, database is the database name. The name is case-insensitive. The server converts the name to lowercase.
"c:/databases/testdb"
SELECT * FROM SYSIBM.SYSDUMMY1
If you omit the -tracing parameter, tracing is disabled.
Example: Test the connection to a data server using IBM Data Server Driver for JDBC and SQLJ type 4 connectivity. Use the default SQL statement to test the connection. Enable tracing for the test.
java com.ibm.db2.jcc.DB2Jcc
-url jdbc:db2://mysys.myloc.svl.ibm.com:446/MYDB
-user db2user -password db2pass -tracing
SELECT COUNT(*) FROM EMPLOYEE
Disable
tracing for the test.java com.ibm.db2.jcc.DB2Jcc
-url jdbc:db2:MYDB
-user db2user -password db2pass
-sql 'SELECT COUNT(*) FROM EMPLOYEE'