de.esprit.appsuite.database.dbase

## Class DBSupport

- java.lang.Object
- - de.esprit.appsuite.database.dbase.DBSupport

-     public class DBSupport
      extends java.lang.Object

  This class convenience routines for database access
  Author:
    Rainer Buesch

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DBSupport(javax.sql.DataSource cp)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `deleteRecords(java.lang.String tableName, SqlCondition condition)` Deletes the records from the given table with the given condition
    `int` | `executeSQL(java.lang.String sql)` Executes the given SQL statement.
    `java.sql.DatabaseMetaData` | `getDatabaseMetaData()`
    `int` | `getRecordCount(java.lang.String table)` Counts the number of records in the given table.
    `java.lang.String` | `printSQL(java.lang.String sql)`
    `int` | `readMaxValue(java.lang.String table, java.lang.String column)` Reads the maximum value in the given table column.
    `int` | `readMaxValue(java.lang.String table, java.lang.String column, SqlCondition cond)` Reads the maximum value in the given table column.
    `java.util.List<java.lang.String>` | `readSchemas()`
    `JdbcTable` | `readTable(java.lang.String schema, java.lang.String tableNamePattern, java.lang.String[] validTableTypes)` Returns the JdbcTable that matches the tableNamePattern or null if none was found.
    `java.util.List<JdbcTable>` | `readTables(java.lang.String schema, java.lang.String[] validTableTypes)`
    `int` | `updateColumnValue(java.lang.String tableName, java.lang.String columnName, java.lang.String columnValue, SqlCondition condition)` Update a table column with the given value in all records that match the given condition

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DBSupport

          public DBSupport(javax.sql.DataSource cp)

  - ### Method Detail

    - #### readTables

          public java.util.List<JdbcTable> readTables(java.lang.String schema,
                                             java.lang.String[] validTableTypes)
                                               throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readTable

          public JdbcTable readTable(java.lang.String schema,
                            java.lang.String tableNamePattern,
                            java.lang.String[] validTableTypes)
                              throws java.lang.Exception

      Returns the JdbcTable that matches the tableNamePattern or null if none was found. Note: because the tableNamePattern is case sensitive in JDBC this method tries upperCase first and if no hit was found, another attempt with lowerCase is done.
      Throws:
        `java.lang.Exception`

    - #### getDatabaseMetaData

          public java.sql.DatabaseMetaData getDatabaseMetaData()
                                                        throws java.sql.SQLException

      Throws:
        `java.sql.SQLException`

    - #### readSchemas

          public java.util.List<java.lang.String> readSchemas()
                                                       throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### executeSQL

          public int executeSQL(java.lang.String sql)
                         throws java.lang.Exception

      Executes the given SQL statement.
      Returns:
        the number of affected records or -1 if the statement failed.
      Throws:
        `java.lang.Exception`

    - #### deleteRecords

          public int deleteRecords(java.lang.String tableName,
                          SqlCondition condition)
                            throws java.lang.Exception

      Deletes the records from the given table with the given condition
      Parameters:
        `condition` - the SQL filter condition, may be null.
      Throws:
        `java.lang.Exception`

    - #### updateColumnValue

          public int updateColumnValue(java.lang.String tableName,
                              java.lang.String columnName,
                              java.lang.String columnValue,
                              SqlCondition condition)
                                throws java.lang.Exception

      Update a table column with the given value in all records that match the given condition
      Parameters:
        `columnValue` - the value of the column, may be null. String values must be single quoted
        `condition` - the SQL filter condition, may be null.
      Throws:
        `java.lang.Exception`

    - #### readMaxValue

          public int readMaxValue(java.lang.String table,
                         java.lang.String column)
                           throws java.lang.Exception

      Reads the maximum value in the given table column.
      Throws:
        `java.lang.Exception`

    - #### readMaxValue

          public int readMaxValue(java.lang.String table,
                         java.lang.String column,
                         SqlCondition cond)
                           throws java.lang.Exception

      Reads the maximum value in the given table column.
      Throws:
        `java.lang.Exception`

    - #### getRecordCount

          public int getRecordCount(java.lang.String table)
                             throws java.lang.Exception

      Counts the number of records in the given table.
      Throws:
        `java.lang.Exception`

    - #### printSQL

          public java.lang.String printSQL(java.lang.String sql)

Copyright © 2014 EsprIT-Systems. All Rights Reserved.