Class JDBCLookup

java.lang.Object
com.swiftmq.impl.streams.comp.jdbc.JDBCLookup

public class JDBCLookup extends Object
Facade to perform queries on a JDBC connected database.
Author:
IIT Software GmbH, Muenster/Germany, (c) 2016, All Rights Reserved
  • Constructor Details

  • Method Details

    • driver

      public JDBCLookup driver(String driver)
      Sets the JDBC driver class name.
      Parameters:
      driver - class name
      Returns:
      JDBCLookup
    • url

      public JDBCLookup url(String url)
      Sets the JDBC URL.
      Parameters:
      url - JDBC URL
      Returns:
      JDBCLookup
    • schema

      public JDBCLookup schema(String schema)
      Sets the database schema name.
      Parameters:
      schema - schema name
      Returns:
      JDBCLoopkup
    • username

      public JDBCLookup username(String username)
      Sets the JDBC username.
      Parameters:
      username - JDBC username
      Returns:
      JDBCLookup
    • password

      public JDBCLookup password(String password)
      Sets the JDBC password.
      Parameters:
      password - JDBC password
      Returns:
      JDBCLookup
    • connect

      public JDBCLookup connect() throws Exception
      Performs a connect to the database.
      Returns:
      JDBCLookup
      Throws:
      Exception - if any error occurs
    • query

      public Memory query(String sql) throws Exception
      Performs a select query and returns a Memory with the result. For every selected database row a single Message is created. For each column of a row a message property is created with the name of the column and the value as the corresponding Java type (String, Integer, Long, Double, Float). A column which returns BigDecimal as value type is converted into a Double.
      Parameters:
      sql - Select statement
      Returns:
      Memory with the result
      Throws:
      Exception - if any error occurs
    • collect

      public void collect(long interval)
      Internal use.
    • close

      public void close()
      Closes the underlying JDBC connection. This is automatically called when the stream is stopped but can also be called from a script if the JDBCLookup object isn't used anymore.