DBManager (The Data Transfer Agent Service 2.1.0-3.10.1 API)
Date: 2016-03-03

org.gcube.datatransfer.agent.impl.db

## Class DBManager

- java.lang.Object
- - org.gcube.datatransfer.agent.impl.db.DBManager

- Direct Known Subclasses:
    DataTransferDBManager

      public abstract class DBManager
      extends Object

  Author:
    Andrea Manzi(CERN)

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `DBManager.BaseConsumer`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static File` | `backupFolder`
    `protected static int` | `backupIntervalMS`
    `protected String` | `dbFileBaseFolder` dbFileName is used to open or create files that hold the state of the db.
    `protected String` | `dbFileName`
    `protected String` | `dbName`
    `protected javax.jdo.PersistenceManagerFactory` | `persistenceFactory`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DBManager()` Constructor for SQLDBManager

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `backup()` checkpoint the db and create a backup
    `void` | `close()` Shutdown the db and close the connection to the db.
    `String` | `queryJSON(String expression)` Executes SQL command SELECT and invokes the given consumer, giging back JSON formatetted output.
    `protected static String` | `quote(String string)` Produce a string in double quotes with backslash sequences in all the right places.
    `static String` | `toJSon(ResultSet resultSet)`
    `protected void` | `zipFolder(File[] files)`

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

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

- - ### Field Detail

    - #### persistenceFactory

          protected javax.jdo.PersistenceManagerFactory persistenceFactory

    - #### backupFolder

          protected static File backupFolder

    - #### dbFileBaseFolder

          protected String dbFileBaseFolder

      dbFileName is used to open or create files that hold the state of the db. It can contain directory names relative to the current working directory

    - #### dbFileName

          protected String dbFileName

    - #### dbName

          protected String dbName

    - #### backupIntervalMS

          protected static int backupIntervalMS

  - ### Constructor Detail

    - #### DBManager

          public DBManager()

      Constructor for SQLDBManager

  - ### Method Detail

    - #### close

          public void close()
                     throws Exception

      Shutdown the db and close the connection to the db.
      Throws:
        `Exception`

    - #### backup

          public void backup()
                      throws SQLException,
                             Exception

      checkpoint the db and create a backup
      Throws:
        `SQLException` - if the CHECKPOINT query fails
        `Exception`

    - #### queryJSON

          public String queryJSON(String expression)
                           throws SQLException,
                                  Exception

      Executes SQL command SELECT and invokes the given consumer, giging back JSON formatetted output.
      Parameters:
        `expression` - the SQL expression to evaluate
      Returns:
        Result Set
      Throws:
        `SQLException` - if the query fails
        `Exception` - if the given resultset consumer fails

    - #### toJSon

          public static String toJSon(ResultSet resultSet)
                               throws SQLException

      Parameters:
        `resultSet` -
      Returns:
        Json String
      Throws:
        `SQLException`

    - #### quote

          protected static String quote(String string)

      Produce a string in double quotes with backslash sequences in all the right places. A backslash will be inserted within
      Parameters:
        `string` - A String
      Returns:
        A String correctly formatted for insertion in a JSON text.

    - #### zipFolder

          protected void zipFolder(File[] files)
                            throws Exception

      Throws:
        `Exception`

Copyright © 2016. All Rights Reserved.