Input genjdbc

genjdbc

Milestone: 1

Synopsis

Connects to datasources using JDBC driver, executes a select query and for each record returned, emits an event.

input {
  genjdbc {
    <a href="#jdbcHost">jdbcHost</a> => ... # string (required)
    <a href="#jdbcPort">jdbcPort</a> => ... # string (required)
    <a href="#jdbcDBName">jdbcDBName</a> => ... # string (required)
    <a href="#jdbcTargetDB">jdbcTargetDB</a> => ... # string (required)
    <a href="#jdbcDriverPath">jdbcDriverPath</a> => ... # string (required)
    <a href="#jdbcUser">jdbcUser</a> => ... # string (required)
    <a href="#jdbcPassword">jdbcPassword</a> => ... # string (required)
    <a href="#jdbcSQLQuery">jdbcSQLQuery</a> => ... # string (required)
    <a href="#jdbcURL">jdbcURL</a> => ... # string (optional)
    <a href="#jdbcTimeField">jdbcTimeField</a> => ... # string (optional)
    <a href="#jdbcPollInterval">jdbcPollInterval</a> => ... # number (optional), default: 60
    <a href="#jdbcCollectionStartTime">jdbcCollectionStartTime</a> => ... # string (optional)
    <a href="#jdbcPStoreFile">jdbcPStoreFile</a> => ... # string (optional)
    }
 }

Details

This plugin takes basic JDBC configuration information, an SQL query and some timing control. It then runs that queryr (with some additional timing information applied) in a loop, emitting events corresponding to each row in the returned table. For example


genjdbc {  
  jdbcHost       => 'X.X.X.X'
  jdbcPort       => '50000'
  jdbcTargetDB   => 'db2'
  jdbcDBName     =>'MYDB'
  jdbcUser         => 'myuser' 
  jdbcPassword   => 'mypasswd'
  jdbcDriverPath => '/path/to/my/driver/db2jcc4.jar'
  jdbcSQLQuery    => 'select * from DT_ALARM_HIST where SUPPRESSED_DESC is null'
  jdbcTimeField => 'TSTAMP'
  jdbcPStoreFile => './test.pstore'                        
  jdbcCollectionStartTime => '2015-01-01 00:00:00.000'
}

In the above example. the query will have where 'TSTAMP' >= currentTime' appended to it. currentTime is an internal variable maintained by the plugin which will be incremented on each loop with the timestamp of the last record returned from the query.

jdbcHost

  • Value type is String
  • There is no default for this setting

jdbc host name. Used to form jdbc url

jdbcPort

  • Value type is String
  • There is no default for this setting

jdbc port number. Used to form jdbc url

jdbcDBName

  • Value type is String
  • The default value is ""

Name of database on server / schema name. Used to form jdbc url

jdbcTargetDB

  • Value type is String
  • There is no default value for this item

Target DB name(vendor). used to select appropriate JDBC format. Supported types

  • postgresql
  • oracle
  • db2
  • mysql
  • derby
  • mssql
  • jdbcDriverPath

    • Value type is String
    • There is no default value for this item

    path to jdbc driver

    jdbcUser

    • Value type is String
    • There is no default value for this item

    jdbc user name. Used to form jdbc url

    jdbcPassword

    • Value type is String
    • There is no default value for this item

    jdbc password. Used to form jdbc url

    jdbcSQLQuery

    • Value type is String
    • There is no default value for this item

    SQL query to execute or the path of a text file which contains the query to execute.

    jdbcSQLQuery => "select * from myTable"

    In the latter case, prefix the filename with 'file:' e.g.

    jdbcSQLQuery => "file:/path/to/my/query.txt"

    jdbcURL

    • Value type is String
    • There is no default value for this item

    jdbc URL - explicitly set the jdbc URL string. Overrides all other URL component settings (e.g jdbcHost, jdbcPort)

    jdbcTimeField

    • Value type is String
    • There is no default value for this item

    Name of the table column which contains timestamp information. This string will be used in the automatically generated SQL query as part of the where clause.

    jdbcPollInterval

    The number of seconds to wait between query loops. A query loop executes the query, waits for a response, processes the response ( by emitting events). Once these steps are completed, the plugin will wait the specified amount of time before starting again and invoking the query.

    jdbcCollectionStartTime

    • Value type is String
    • There is no default value for this item

    This is a timestamp expressed as a string e.g. '2015-01-01 00:00:00.000'. It will be used in direct comparison operations against the specified jdbcTimeField so the precise format depends on the database and the nature of the time column referenced.

    jdbcPStoreFile

    • Value type is String
    • There is no default value for this item

    The pathname of a file which is used to maintain state for this operator. It is useful to be able to specify this as you may have multiple genjdbc plugins.