JDBC Input Adapter

The JDBC Input adapter attempts to establish a JDBC session with the specified database. It then executes the given query periodically based on the specified frequency.

Each time the query is submitted, the data stream gets rows that have columns with names and types equivalent to those selected from the source table. The SQL types that map to CCL data types are shown in the Datatype Mappings table in JDBC Output Adapter .

This adapter is run as an out-of-process adapter.

Set your CLASSPATH environment variable according to the instructions in Sybase CEP Java SDK. The instructions for setting CLASSPATH apply to all out-of-process Java adapters, whether provided by Sybase CEP or written by you.

Execute the following command:


java com.sybase.c8.adapter.JDBCInputAdapter <parameters>

Each parameter is of the form

--<paramname>=<paramvalue>

For example, the beginning of such a command line will look similar to the following:


java com.sybase.c8.adapter.JDBCInputAdapter --queryFile=q1.sql ...

Note that "--" (two dashes) must precede each parameter name.

Use the command-line parameters shown in the table below. These parameters are case-sensitive.

Parameter

Description

Required/Optional

queryFile

A file with the SQL query, which can be almost any SQL statement that is valid for the database that the adapter is connected to. The query can be parameterized.

Required

username

The username with which to log into the database.

Required

password

The password for the specified user name.

Required

databaseUrl

A database address in the standard form used by JDBC. For example, --databaseUrl=jdbc:oracle:oci8:@oracle.

Required

streamUrl

The URL of the stream to send tuples to.

Required

driver

The database driver to use. For example: --driver=oracle.jdbc.driver.OracleDrive. Sybase CEP does not bundle JDBC drivers with the product, so customers must provide the drivers themselves. In order for the Sybase CEP JDBC Input adapter to work, the JDBC driver must be included in the Java CLASSPATH, as well as pass the driver on the command line.

Required

pollInterval

Frequency in microseconds with which to periodically resubmit the query.

Required

tupleDescriptorFile

The name of a file with a tuple descriptor that describes the schema that you are publishing to. See the discussion of the tupleDescriptor File below.

Required

fetchSize

The size of the batch to read from the database and accumulate before sending tuples to the stream. (The default is 10.)

Optional

incrementalUpdates

If this is set to true, the adapter adds the retrieved rows to the existing rows. If this is set to false, the adapter replaces all the rows each time that the query is executed. Set this to true if you are repeatedly retrieving the same relatively small, semi-static data set.

Optional

Each input stream has a property (see the stream's Properties tab in Studio) that can specify whether to use the current server timestamp value instead of the row timestamp set by the adapter. If this stream property is set to true, it overrides any row timestamp set by the adapter.

After the adapter starts, it initializes its connection to Sybase CEP Server and the remote database server. The adapter then sleeps the initial hard-coded time and then starts executing the query against the database.

To shut down the adapter, send an interrupt signal (for example, ctrl-C).

Like any out-of-process adapter, this adapter requires that the server and query module already be running, and that the stream exists so that the adapter can attach to it.