Package cdc.rdb

Class RdbHelper

java.lang.Object
cdc.rdb.RdbHelper

public class RdbHelper extends Object
Helper class for DB handling.
Author:
Damien Carbonne
  • Constructor Details

  • Method Details

    • getCatalogSeparator

      public String getCatalogSeparator()
      Returns:
      The catalog separator.
    • getIdentifierQuoteString

      public String getIdentifierQuoteString()
      Returns:
      The identifier quote string.
    • wrapIdentifier

      public String wrapIdentifier(String id)
      Parameters:
      id - The naked identifier.
      Returns:
      id wrapped with identifier quote string.
    • getQueryTableName

      public String getQueryTableName(String schemaName, String tableName)
      Parameters:
      schemaName - The schema name.
      tableName - The table name.
      Returns:
      The String designating the table identified by schemaName and tableName.
    • getSelectClause

      public String getSelectClause(String schemaName, String tableName)
      Parameters:
      schemaName - The schema name.
      tableName - The table name.
      Returns:
      SELECT * FROM TTT
      where TTT is the table name.
    • getTableSizeQuery

      public String getTableSizeQuery(String schemaName, String tableName)
      Parameters:
      schemaName - The schema name.
      tableName - The table name.
      Returns:
      SELECT COUNT (*) FROM TTT
      where TTT is the table name.
    • getInsertIntoTableQuery

      public String getInsertIntoTableQuery(String schemaName, String tableName, int columns)
      Parameters:
      schemaName - The schema name.
      tableName - The table name.
      columns - The number of columns.
      Returns:
      INSERT INTO TTT VALUES(?,?,...)
      where TTT is the table name.
    • getInsertIntoTableQuery

      public String getInsertIntoTableQuery(String schemaName, String tableName, List<String> columnsNames)
      Parameters:
      schemaName - The schema name.
      tableName - The table name.
      columnsNames - The columns names.
      Returns:
      INSERT INTO TTT (N1, N2, ...) VALUES (?,?,...)
      where TTT is the table name
      and Ni is the i-th column name.
    • getDeleteFromTableQuery

      public String getDeleteFromTableQuery(String schemaName, String tableName, List<String> whereColumnsNames)
    • getUpdateTableQuery

      public String getUpdateTableQuery(String schemaName, String tableName, List<String> setColumnsNames, List<String> whereColumnsNames)
    • getTableSize

      public long getTableSize(Connection connection, String schemaName, String tableName) throws SQLException
      Parameters:
      connection - The connection.
      schemaName - The schema name.
      tableName - The table name.
      Returns:
      The size of the table designated by schemaName and tableName.
      Throws:
      SQLException - When an SQL error occurs.
    • getOrderClause

      public String getOrderClause(List<RdbColumnSorting> sortings)
      Parameters:
      sortings - The columns sortings.
      Returns:
      A String defining an order clause based on sortings.
    • print

      public static void print(ResultSet rs, PrintStream out)