Database Input Adapter with Polling

Use a Database Input adapter to connect to and poll a database.

Prerequisites

To run this example, create a Trades table in your database using the supported syntax. The table should include these values:
Column Datatype Value
Ts datetime not null
Symbol char(4) not null
Price money not null
Volume int not null

You also need to create a unique non-clustered index called ind1 on Trades (Ts), and grant all permissions on Trades to public.

Finally, configure the services.xml file in <ESP_HOME>/bin using the following example as a model for configuration:
<Service Name="dbExample" Type="DB">

                <Parameter Name="DriverLibrary">esp_db_jdbc_sybase_lib</Parameter>
                <Parameter Name="Host">mydbserver</Parameter>
                <Parameter Name="Port">5000</Parameter>
                <Parameter Name="User">test4</Parameter>
                <Parameter Name="Password">password</Parameter>
                <Parameter Name="Database">interpubs</Parameter>
                <Parameter Name="ConnectString"></Parameter>
                <Parameter Name="ConnectionPoolSize">-1</Parameter>
        </Service>



Populate the table with data, then run the example.

Example

The example creates a schema named TradeSchema, followed by an input window named TradeWindow and output window named TradeOutWindow that each reference TradeSchema. SELECT all (*) syntax outputs all data processed by TradeWindow to TradeOutWindow.

The example attaches a Database Input adapter to TradeWindow to read data from the database you set up as a prerequisite. A poll period of 10 for this adapter instance means that the database is polled for new content every 10 seconds.

ATTACH INPUT ADAPTER dbInConn1
 TYPE db_in
 TO TradeWindow
 PROPERTIES service = 'dbExample' ,
  query = 'Select * from Trades' , 
  table = 'Trades' , 
  pollperiod =0 , 
  dateFormat = '%Y-%m-%d %H:%M:%S' , timestampFormat = '%Y-%m-%d %H:%M:%S' ;