Connecting to an event source using JDBC

Connecting to an event source involves downloading and installing the JDBC driver, and specifying appropriate values for the connection-related properties.

JDBC drivers

You must obtain the JDBC driver for the target database from the database vendor and install it according to the vendor's instructions. The drivers are usually provided as Java™ archives (.jar).

Setting the CLASSPATH variable

Environment variables are specific preset values that establish the working environment of the probe. From the environment variable specified, the probe receives path information for the directories in which library files are present.

Set the CLASSPATH variable to the full path of the JDBC jar file that you installed for your datasource. For example:

c:\\DB2\\db2jcc.jar

On UNIX or Linux operating systems, use the following command:

export CLASSPATH=/home/jdbc_driver

where jdbc_driver is the full path of the JDBC jar file that you installed for your datasource.

On Windows operating systems, use the following command:

set CLASSPATH=c:\jdbc_driver

where jdbc_driver is the full path of the JDBC jar file that you installed for your datasource.

Database connection properties

To enable the probe to communicate with the target database, you must specify values for the following properties:
  • JdbcDriver: This property specifies the JDBC driver required to connect the database.
  • JdbcUrl: This property specifies the URL of the target database.
  • DBUsername: This property specifies the user name for the target database.
  • DBPassword: This property specifies the password for the target database.

The format in which you specify the JdbcDriver and JdbcUrl properties depend on the type of database to which the probe is connecting.

The following table lists example values for the JdbcDriver and JdbcUrl properties for use with each database supported by the probe. Consult your driver documentation for more information about setting up database connections. Default values may be different depending on your setup.

Table 1. Example JDBC property values

DB2® LUW

JdbcDriver

com.ibm.db2.jcc.DB2Driver

JdbcUrl

jdbc:db2://host_name:port/db_name

Where host_name is the name of the database host machine, port is the port number, and db_name is the name of the database. For example:

jdbc:db2://server.example.ibm.com:9999/REPORTER

DB2 z/OS®

JdbcDriver

com.ibm.db2.jcc.DB2Driver

JdbcUrl

jdbc:db2://host_name:port/db_name

Where host_name is the name of the database host machine, port is the port number, and db_name is the name of the database. For example:

jdbc:db2://server.example.ibm.com:9999/REPORTER

Informix®

JdbcDriver

com.informix.jdbc.IfxDriver

JdbcUrl

jdbc:informix-sqli://host_name:port/db_name:INFORMIXSERVER=server_name

Where host_name is the name of the database host machine, port is the port number, db_name is the name of the database, and server_name is the same as the host_name. For example:

jdbc:informix-sqli://server.example.ibm.com:1433/REPORTER:INFORMIXSERVER=server.example.ibm.com

Microsoft SQL Server

JdbcDriver

com.microsoft.sqlserver.jdbc.SQLServerDriver

JdbcUrl

jdbc:sqlserver://host_name:port;databaseName=db_name

Where host_name is the name of the database host machine, port is the port number, and db_name is the name of the database. The default port is 1433. For example:

jdbc:sqlserver://server.example.ibm.com:1433;databaseName=REPORTER

MySQL

JdbcDriver

com.mysql.jdbc.Driver

JdbcUrl

jdbc:mysql://host_name[,failover_host]:port/db_name[?param1=value1&param2=value2]

Where host_name is the name of the database host machine, failover_host is the name of the optional failover host, port is the port number, db_name is the name of the database, and param1 and param2 are optional parameters. The default port is 3306. For example:

jdbc:mysql://server.example.ibm.com:3306/alerts

Oracle

JdbcDriver

oracle.jdbc.driver.OracleDriver

JdbcUrl

jdbc:oracle:thin:@host_name:port:db_name

Where host_name is the name of the database host machine, port is the port number, and db_name is the name of the database. The default port is 1521. For example:

jdbc:oracle:thin:@server.example.ibm.com:1521: REPORTER

Sybase

JdbcDriver

com.sybase.jdbc4.jdbc.SybDriver

JdbcUrl

jdbc:sybase:Tds:host_name:port/db_name[?property=value;]

Where host_name is the name of the database host machine, port is the port number, db_name is the name of the database, and property is an optional parameter. For example:

jdbc:sybase:Tds:server.example.ibm.com:1521/REPORTER