Database Input Adapter

Use the Database Input adapter to connect to 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 must also create a unique index named ind1 on Trades (Ts) and grant all permissions on Trades to public.

Finally, configure the services.xml file in <ESP_HOME>/bin using this example as a model:
<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 before running the example.

Example

The example creates a schema named TradeSchema, followed by an input window named TradeWindow and an output window named TradeOutWindow that each reference TradeSchema. SELECT all (*) syntax tells the project server to output 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.

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' ;