tigase.db.jdbc

## Class DataRepositoryImpl

- java.lang.Object
- - tigase.db.jdbc.DataRepositoryImpl

- All Implemented Interfaces:
    DataRepository

      public class DataRepositoryImpl
      extends Object
      implements DataRepository

  Created: Sep 3, 2010 5:55:41 PM
  Version:
    $Rev$
  Author:
    Artur Hefczyc

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DB_CONN_TIMEOUT` Field description
    `static String` | `DB_CONN_TIMEOUT_PROP_KEY`
    `static String` | `DERBY_CHECK_TABLE_QUERY` Field description
    `static String` | `DERBY_CONNVALID_QUERY` Field description
    `static String` | `JDBC_CONNVALID_QUERY` Field description
    `static String` | `MYSQL_CHECK_TABLE_QUERY` Field description
    `static String` | `OTHER_CHECK_TABLE_QUERY` Field description
    `static String` | `PGSQL_CHECK_TABLE_QUERY` Field description
    `static int` | `QUERY_TIMEOUT` Field description
    `static String` | `QUERY_TIMEOUT_PROP_KEY`
    `static String` | `SP_STARTS_WITH` Field description

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DataRepositoryImpl()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `checkTable(String tableName)` Method description
    `boolean` | `checkTable(String tableName, String createTableQuery)` The method checks whether a table for the given name exists in the database and if it does not, it automatically creates it.
    `void` | `commit()` Commits current transaction on the DataRepository connection.
    `Statement` | `createStatement(tigase.xmpp.BareJID user_id)` Method description
    `void` | `endTransaction()` Ends current transaction on the DataRepository connection.
    `protected int` | `getParam(String key, Map<String,String> params, int def)`
    `PreparedStatement` | `getPreparedStatement(tigase.xmpp.BareJID user_id, String stIdKey)` Method description
    `String` | `getResourceUri()` Method description
    `void` | `initPreparedStatement(String key, String query)` Method description
    `void` | `initRepository(String resource_uri, Map<String,String> params)` Method description
    `void` | `release(Statement stmt, ResultSet rs)` Method description
    `void` | `releaseRepoHandle(DataRepository repo)`
    `void` | `rollback()` Rolls back started transaction on the DataRepository connection.
    `void` | `startTransaction()` Starts transaction on the DataRepository connection.
    `DataRepository` | `takeRepoHandle(tigase.xmpp.BareJID user_id)` Returns `DataRepository` instance.

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

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

- - ### Field Detail

    - #### DERBY_CONNVALID_QUERY

          public static final String DERBY_CONNVALID_QUERY

      Field description
      See Also:
        Constant Field Values

    - #### JDBC_CONNVALID_QUERY

          public static final String JDBC_CONNVALID_QUERY

      Field description
      See Also:
        Constant Field Values

    - #### MYSQL_CHECK_TABLE_QUERY

          public static final String MYSQL_CHECK_TABLE_QUERY

      Field description
      See Also:
        Constant Field Values

    - #### PGSQL_CHECK_TABLE_QUERY

          public static final String PGSQL_CHECK_TABLE_QUERY

      Field description
      See Also:
        Constant Field Values

    - #### DERBY_CHECK_TABLE_QUERY

          public static final String DERBY_CHECK_TABLE_QUERY

      Field description
      See Also:
        Constant Field Values

    - #### OTHER_CHECK_TABLE_QUERY

          public static final String OTHER_CHECK_TABLE_QUERY

      Field description
      See Also:
        Constant Field Values

    - #### SP_STARTS_WITH

          public static final String SP_STARTS_WITH

      Field description
      See Also:
        Constant Field Values

    - #### QUERY_TIMEOUT_PROP_KEY

          public static final String QUERY_TIMEOUT_PROP_KEY

      See Also:
        Constant Field Values

    - #### QUERY_TIMEOUT

          public static final int QUERY_TIMEOUT

      Field description
      See Also:
        Constant Field Values

    - #### DB_CONN_TIMEOUT_PROP_KEY

          public static final String DB_CONN_TIMEOUT_PROP_KEY

      See Also:
        Constant Field Values

    - #### DB_CONN_TIMEOUT

          public static final int DB_CONN_TIMEOUT

      Field description
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### DataRepositoryImpl

          public DataRepositoryImpl()

  - ### Method Detail

    - #### checkTable

          public boolean checkTable(String tableName)
                             throws SQLException

      Method description
      Specified by:
        `checkTable` in interface `DataRepository`
      Parameters:
        `tableName` -
      Returns:
      Throws:
        `SQLException`

    - #### checkTable

          public boolean checkTable(String tableName,
                           String createTableQuery)
                             throws SQLException

      Description copied from interface: `DataRepository`
      The method checks whether a table for the given name exists in the database and if it does not, it automatically creates it.
      Specified by:
        `checkTable` in interface `DataRepository`
      Parameters:
        `tableName` - is a `String` value of the table name to check
        `createTableQuery` - is a `String` with the query to create table
      Returns:
        `true` `boolean` value if the table exist in the database and `false` if the table was not found.
      Throws:
        `SQLException` - if there was a problem accessing database.

    - #### createStatement

          public Statement createStatement(tigase.xmpp.BareJID user_id)
                                    throws SQLException

      Method description
      Specified by:
        `createStatement` in interface `DataRepository`
      Returns:
      Throws:
        `SQLException`

    - #### getPreparedStatement

          public PreparedStatement getPreparedStatement(tigase.xmpp.BareJID user_id,
                                               String stIdKey)
                                                 throws SQLException

      Method description
      Specified by:
        `getPreparedStatement` in interface `DataRepository`
      Parameters:
        `stIdKey` -
      Returns:
      Throws:
        `SQLException`

    - #### getResourceUri

          public String getResourceUri()

      Method description
      Specified by:
        `getResourceUri` in interface `DataRepository`
      Returns:

    - #### initPreparedStatement

          public void initPreparedStatement(String key,
                                   String query)
                                     throws SQLException

      Method description
      Specified by:
        `initPreparedStatement` in interface `DataRepository`
      Parameters:
        `key` -
        `query` -
      Throws:
        `SQLException`

    - #### initRepository

          public void initRepository(String resource_uri,
                            Map<String,String> params)
                              throws SQLException

      Method description
      Specified by:
        `initRepository` in interface `DataRepository`
      Parameters:
        `resource_uri` -
        `params` -
      Throws:
        `SQLException`

    - #### getParam

          protected int getParam(String key,
                     Map<String,String> params,
                     int def)

    - #### release

          public void release(Statement stmt,
                     ResultSet rs)

      Method description
      Specified by:
        `release` in interface `DataRepository`
      Parameters:
        `stmt` -
        `rs` -

    - #### takeRepoHandle

          public DataRepository takeRepoHandle(tigase.xmpp.BareJID user_id)

      Description copied from interface: `DataRepository`
      Returns `DataRepository` instance. If this is a repository pool then it returns particular instance from the pool. It this is a real repository instance it returns itself. This is exclusive take, no other thread may use this handle until it is returned to the pool.
      Specified by:
        `takeRepoHandle` in interface `DataRepository`
      Parameters:
        `user_id` - is user account ID for which we acquire the handle.
      Returns:
        DataRepository instance.

    - #### startTransaction

          public void startTransaction()
                                throws SQLException

      Description copied from interface: `DataRepository`
      Starts transaction on the DataRepository connection. Please note that calling this method on the repository pool has no effect. You have to obtain particular repository handle first, before you can start transaction.
      Specified by:
        `startTransaction` in interface `DataRepository`
      Throws:
        `SQLException`

    - #### commit

          public void commit()
                      throws SQLException

      Description copied from interface: `DataRepository`
      Commits current transaction on the DataRepository connection. Please note that calling this method on the repository pool has no effect. You have to obtain particular repository handle first, before you can start transaction.
      Specified by:
        `commit` in interface `DataRepository`
      Throws:
        `SQLException`

    - #### rollback

          public void rollback()
                        throws SQLException

      Description copied from interface: `DataRepository`
      Rolls back started transaction on the DataRepository connection. Please note that calling this method on the repository pool has no effect. You have to obtain particular repository handle first, before you can start transaction.
      Specified by:
        `rollback` in interface `DataRepository`
      Throws:
        `SQLException`

    - #### endTransaction

          public void endTransaction()
                              throws SQLException

      Description copied from interface: `DataRepository`
      Ends current transaction on the DataRepository connection. Please note that calling this method on the repository pool has no effect. You have to obtain particular repository handle first, before you can start transaction.
      Specified by:
        `endTransaction` in interface `DataRepository`
      Throws:
        `SQLException`

    - #### releaseRepoHandle

          public void releaseRepoHandle(DataRepository repo)

      Specified by:
        `releaseRepoHandle` in interface `DataRepository`

Copyright © 2013 Tigase. All rights reserved.