Class JdbcRequester


  • public class JdbcRequester
    extends Object
    A requester of a remote enterprise data source by using the yet configured DataSourceConnectionInfo instance. If no DataSourceConnectionInfo instance is available, then no connection is established and no request can be done.
    Author:
    mmoquillon
    • Constructor Detail

      • JdbcRequester

        public JdbcRequester​(String componentInstanceId)
        Constructs a new JDBC requester for the specified component instance. It loads the DataSourceConnectionInfo instance that was persisted for the specified component instance in order to establish a connection with a remote data source. If there is more than one connection information registered, then we are in an unstable state for the given component instance and a JdbcConnectorRuntimeException is then thrown.
        Parameters:
        componentInstanceId - the unique identifier of a ConnecteurJDBC application instance.
    • Method Detail

      • getCurrentConnectionInfo

        public DataSourceConnectionInfo getCurrentConnectionInfo()
        Gets information about the current JDBC connection used to request the data source.
        Returns:
        a DataSourceConnectionInfo instance with all the information about the connection with the remote data source
      • checkConnection

        public void checkConnection()
                             throws JdbcConnectorException
        Checks the connection with the remote data source referred by the underlying DataSourceConnectionInfo instance used by this requester.

        If the connection cannot be established with the data source, a JdbcConnectorException exception is thrown. This occurs when:

        • no connection information is set for the underlying component instance,
        • the connection information isn't correct,
        • the connection information is correct but the connection with the data source fails at this time.
        Throws:
        JdbcConnectorException - if the connection cannot be established with the data source referred by the DataSourceConnectionInfo instance used by this requester.
      • isDataSourceDefined

        public boolean isDataSourceDefined()
        Is there is a data source set with this requester? A data source is set when there is a DataSourceConnectionInfo instance defined for the component instance to which this requester is related.
        Returns:
        true if there is a DataSourceConnectionInfo instance set with this requester. False otherwise.
      • isSQLRequestDefined

        public boolean isSQLRequestDefined()
        Is there is any default SQL request set with this requester? A request is set when there is a DataSourceConnectionInfo instance defined for the component instance to which this request is related and a SQL query has been defined for that connection information.
        Returns:
        true if there is a SQL query defined for the current underlying connection information.
      • getTableNames

        public List<String> getTableNames()
        Gets all the tables in the data source (only public tables and views are fetched). If an error occurs while requesting the data source, a JdbcConnectorRuntimeException is thrown.
        Returns:
        a list of table names.
      • getColumnNames

        public List<String> getColumnNames​(String tableName)
        Gets all the columns in the specified table.
        Parameters:
        tableName - a name of a table. This name must have been get by invoking getTableNames() method. If an error occurs while requesting the data source, a JdbcConnectorRuntimeException is thrown.
        Returns:
        a list of column names in the given table.