gate.persist
Class DBHelper

java.lang.Object
  |
  +--gate.persist.DBHelper

public class DBHelper
extends Object


Field Summary
static int BINARY_CONTENT
          binary content (may make difference for the database)
static int CHARACTER_CONTENT
          character content (may make difference for the database)
static int CHINK_SIZE_LARGE
           
static int CHINK_SIZE_MEDIUM
           
static int CHINK_SIZE_SMALL
           
static String CORPUS_CLASS
          LR classes supported at present
static String DB_PARAMETER_GUID
          key in T_PARAMETER that defines a unique id for the data store
private static boolean DEBUG
           
static String DOCUMENT_CLASS
          LR classes supported at present
private static boolean driversLoaded
           
static String DUMMY_ENCODING
          dummy encoding type, do not use it
static String DUMMY_FEATURE_KEY
          dummy feature key, do not use it
static Long DUMMY_ID
          huh?
static int EMPTY_CONTENT
          document has no content
static int FALSE
           
protected static int FEATURE_OWNER_ANNOTATION
          used to store annotation's features
protected static int FEATURE_OWNER_CORPUS
          used to store corpus' features
protected static int FEATURE_OWNER_DOCUMENT
          used to store document's features
private static String jdbcOracleDriverName
          class name of the Oracle jdbc driver
private static String jdbcPostgresDriverName
           
static int ORACLE_DB
          Oracle database type
private static int POOL_SIZE
          size (in elements) of the jdbc connection pool (if any)
private static HashMap pools
           
static int POSTGRES_DB
          PostgreSQL database type
static int READ_ACCESS
          used internaly, may change in the future
static int TRUE
           
static int VALUE_TYPE_BINARY
          feature value is binary
static int VALUE_TYPE_BINARY_ARR
          feature value is array of binary values
static int VALUE_TYPE_BOOLEAN
          feature value is boolean
static int VALUE_TYPE_BOOLEAN_ARR
          feature value is array of bools
static int VALUE_TYPE_EMPTY_ARR
          feature value is array of floats
static int VALUE_TYPE_FLOAT
          feature value is float
static int VALUE_TYPE_FLOAT_ARR
          feature value is array of floats
static int VALUE_TYPE_INTEGER
          feature value is int
static int VALUE_TYPE_INTEGER_ARR
          feature value is array of ints
static int VALUE_TYPE_LONG
          feature value is long
static int VALUE_TYPE_LONG_ARR
          feature value is array of longs
static int VALUE_TYPE_NULL
          feature value is null
static int VALUE_TYPE_STRING
          feature value is string less than 4000 bytes
static int VALUE_TYPE_STRING_ARR
          feature value is array of strings
static int WRITE_ACCESS
          used internaly, may change in the future
static int X_ORACLE_DUPLICATE_GROUP_NAME
          this should be thrown if an attempt to create a group with duplicated name is made
static int X_ORACLE_DUPLICATE_USER_NAME
          see above
static int X_ORACLE_GROUP_OWNS_RESOURCES
          attempt to delete a group that owns resources is made
static int X_ORACLE_INCOMPLETE_DATA
          huh?
static int X_ORACLE_INSUFFICIENT_PRIVILEGES
          attempt to perform an operation that requres more privileged is made
static int X_ORACLE_INVALID_ACCESS_MODE
          attempt to access resource in mode that does not exist
static int X_ORACLE_INVALID_ANNOTATION
          attempt to remove annotation that does not exist is made
static int X_ORACLE_INVALID_ANNOTATION_SET
          attempt to remove annotation set that does not exist is made
static int X_ORACLE_INVALID_ANNOTATION_TYPE
          this is obsolete now?
static int X_ORACLE_INVALID_ARGUMENT
          huh?
static int X_ORACLE_INVALID_CONTENT_TYPE
          not supported content type - we support only character/binary/empty content since there are no many other options this error shoudkl indicate that the java code was not synced with the pl/sql one
static int X_ORACLE_INVALID_FEATURE_TYPE
          attempt to create a feature with invalid value type is made since value types are automatically assigned in the java code, this errror should indicate that the java code was changed but no changes were made to the relevant pl/sql code
static int X_ORACLE_INVALID_LR
          access to LR by id fails - no such resource
static int X_ORACLE_INVALID_LR_TYPE
          attempt to access resources by type is made, but no such type exists
static int X_ORACLE_INVALID_USER_GROUP
          invalid group id supplied for operation requiring such specifier
static int X_ORACLE_INVALID_USER_NAME
          no such user failure upon login
static int X_ORACLE_INVALID_USER_PASS
          -
static int X_ORACLE_NOT_IMPLEMENTED
          this should not be in use anymore
static int X_ORACLE_START
          user defined error codes in Oracle start with -21000
static int X_ORACLE_USER_OWNS_RESOURCES
          attempt to delete a user that owns resources is made
 
Constructor Summary
protected DBHelper()
           
 
Method Summary
(package private) static void ()
           
static void cleanup(ResultSet rs)
          closes a result set note that Oracle jdbc classes do not have finalize() implementations so if they're not closed leaks may occur
static void cleanup(Statement stmt)
          closes a statement note that Oracle jdbc classes do not have finalize() implementations so if they're not closed leaks may occur
static Connection connect(String connectURL)
          connects to DB
static Connection connect(String connectURL, boolean usePool)
          connects to DB gets connection from pool if such exists
static Connection connect(String connectURL, String user, String pass)
          connects to DB
static void disconnect(Connection conn)
          disconnects from DB, may return connection to pool if such exists any uncommited transactions are rolled back
static void disconnect(Connection conn, boolean usePool)
          disconnects from DB, may return connection to pool if such exists any uncommited transactions are rolled back
static int getDatabaseType(String jdbcURL)
           
static String getSchemaPrefix(String jdbcURL)
           
private static void loadDrivers()
          ---
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

jdbcOracleDriverName

private static final String jdbcOracleDriverName
class name of the Oracle jdbc driver

jdbcPostgresDriverName

private static final String jdbcPostgresDriverName

CHINK_SIZE_SMALL

public static final int CHINK_SIZE_SMALL

CHINK_SIZE_MEDIUM

public static final int CHINK_SIZE_MEDIUM

CHINK_SIZE_LARGE

public static final int CHINK_SIZE_LARGE

X_ORACLE_START

public static final int X_ORACLE_START
user defined error codes in Oracle start with -21000

X_ORACLE_DUPLICATE_GROUP_NAME

public static final int X_ORACLE_DUPLICATE_GROUP_NAME
this should be thrown if an attempt to create a group with duplicated name is made

X_ORACLE_DUPLICATE_USER_NAME

public static final int X_ORACLE_DUPLICATE_USER_NAME
see above

X_ORACLE_INVALID_USER_NAME

public static final int X_ORACLE_INVALID_USER_NAME
no such user failure upon login

X_ORACLE_INVALID_USER_PASS

public static final int X_ORACLE_INVALID_USER_PASS
-

X_ORACLE_INVALID_USER_GROUP

public static final int X_ORACLE_INVALID_USER_GROUP
invalid group id supplied for operation requiring such specifier

X_ORACLE_INVALID_LR

public static final int X_ORACLE_INVALID_LR
access to LR by id fails - no such resource

X_ORACLE_INVALID_ACCESS_MODE

public static final int X_ORACLE_INVALID_ACCESS_MODE
attempt to access resource in mode that does not exist

X_ORACLE_INVALID_ARGUMENT

public static final int X_ORACLE_INVALID_ARGUMENT
huh?

X_ORACLE_NOT_IMPLEMENTED

public static final int X_ORACLE_NOT_IMPLEMENTED
this should not be in use anymore

X_ORACLE_GROUP_OWNS_RESOURCES

public static final int X_ORACLE_GROUP_OWNS_RESOURCES
attempt to delete a group that owns resources is made

X_ORACLE_USER_OWNS_RESOURCES

public static final int X_ORACLE_USER_OWNS_RESOURCES
attempt to delete a user that owns resources is made

X_ORACLE_INCOMPLETE_DATA

public static final int X_ORACLE_INCOMPLETE_DATA
huh?

X_ORACLE_INVALID_LR_TYPE

public static final int X_ORACLE_INVALID_LR_TYPE
attempt to access resources by type is made, but no such type exists

X_ORACLE_INVALID_ANNOTATION_TYPE

public static final int X_ORACLE_INVALID_ANNOTATION_TYPE
this is obsolete now?

X_ORACLE_INVALID_FEATURE_TYPE

public static final int X_ORACLE_INVALID_FEATURE_TYPE
attempt to create a feature with invalid value type is made since value types are automatically assigned in the java code, this errror should indicate that the java code was changed but no changes were made to the relevant pl/sql code

X_ORACLE_INVALID_CONTENT_TYPE

public static final int X_ORACLE_INVALID_CONTENT_TYPE
not supported content type - we support only character/binary/empty content since there are no many other options this error shoudkl indicate that the java code was not synced with the pl/sql one

X_ORACLE_INVALID_ANNOTATION

public static final int X_ORACLE_INVALID_ANNOTATION
attempt to remove annotation that does not exist is made

X_ORACLE_INSUFFICIENT_PRIVILEGES

public static final int X_ORACLE_INSUFFICIENT_PRIVILEGES
attempt to perform an operation that requres more privileged is made

X_ORACLE_INVALID_ANNOTATION_SET

public static final int X_ORACLE_INVALID_ANNOTATION_SET
attempt to remove annotation set that does not exist is made

TRUE

public static final int TRUE

FALSE

public static final int FALSE

CHARACTER_CONTENT

public static final int CHARACTER_CONTENT
character content (may make difference for the database)

BINARY_CONTENT

public static final int BINARY_CONTENT
binary content (may make difference for the database)

EMPTY_CONTENT

public static final int EMPTY_CONTENT
document has no content

DOCUMENT_CLASS

public static final String DOCUMENT_CLASS
LR classes supported at present

CORPUS_CLASS

public static final String CORPUS_CLASS
LR classes supported at present

DB_PARAMETER_GUID

public static final String DB_PARAMETER_GUID
key in T_PARAMETER that defines a unique id for the data store

DUMMY_FEATURE_KEY

public static final String DUMMY_FEATURE_KEY
dummy feature key, do not use it

DUMMY_ENCODING

public static final String DUMMY_ENCODING
dummy encoding type, do not use it

READ_ACCESS

public static final int READ_ACCESS
used internaly, may change in the future

WRITE_ACCESS

public static final int WRITE_ACCESS
used internaly, may change in the future

DUMMY_ID

public static final Long DUMMY_ID
huh?

FEATURE_OWNER_CORPUS

protected static final int FEATURE_OWNER_CORPUS
used to store corpus' features

FEATURE_OWNER_DOCUMENT

protected static final int FEATURE_OWNER_DOCUMENT
used to store document's features

FEATURE_OWNER_ANNOTATION

protected static final int FEATURE_OWNER_ANNOTATION
used to store annotation's features

VALUE_TYPE_NULL

public static final int VALUE_TYPE_NULL
feature value is null

VALUE_TYPE_INTEGER

public static final int VALUE_TYPE_INTEGER
feature value is int

VALUE_TYPE_LONG

public static final int VALUE_TYPE_LONG
feature value is long

VALUE_TYPE_BOOLEAN

public static final int VALUE_TYPE_BOOLEAN
feature value is boolean

VALUE_TYPE_STRING

public static final int VALUE_TYPE_STRING
feature value is string less than 4000 bytes

VALUE_TYPE_BINARY

public static final int VALUE_TYPE_BINARY
feature value is binary

VALUE_TYPE_FLOAT

public static final int VALUE_TYPE_FLOAT
feature value is float

VALUE_TYPE_INTEGER_ARR

public static final int VALUE_TYPE_INTEGER_ARR
feature value is array of ints

VALUE_TYPE_LONG_ARR

public static final int VALUE_TYPE_LONG_ARR
feature value is array of longs

VALUE_TYPE_BOOLEAN_ARR

public static final int VALUE_TYPE_BOOLEAN_ARR
feature value is array of bools

VALUE_TYPE_STRING_ARR

public static final int VALUE_TYPE_STRING_ARR
feature value is array of strings

VALUE_TYPE_BINARY_ARR

public static final int VALUE_TYPE_BINARY_ARR
feature value is array of binary values

VALUE_TYPE_FLOAT_ARR

public static final int VALUE_TYPE_FLOAT_ARR
feature value is array of floats

VALUE_TYPE_EMPTY_ARR

public static final int VALUE_TYPE_EMPTY_ARR
feature value is array of floats

ORACLE_DB

public static final int ORACLE_DB
Oracle database type

POSTGRES_DB

public static final int POSTGRES_DB
PostgreSQL database type

DEBUG

private static final boolean DEBUG

driversLoaded

private static boolean driversLoaded

pools

private static HashMap pools

POOL_SIZE

private static final int POOL_SIZE
size (in elements) of the jdbc connection pool (if any)
Constructor Detail

DBHelper

protected DBHelper()
Method Detail

static void ()

loadDrivers

private static void loadDrivers()
                         throws ClassNotFoundException
---

cleanup

public static void cleanup(ResultSet rs)
                    throws PersistenceException
closes a result set note that Oracle jdbc classes do not have finalize() implementations so if they're not closed leaks may occur

cleanup

public static void cleanup(Statement stmt)
                    throws PersistenceException
closes a statement note that Oracle jdbc classes do not have finalize() implementations so if they're not closed leaks may occur

connect

public static Connection connect(String connectURL)
                          throws SQLException,
                                 ClassNotFoundException
connects to DB

connect

public static Connection connect(String connectURL,
                                 String user,
                                 String pass)
                          throws SQLException,
                                 ClassNotFoundException
connects to DB

disconnect

public static void disconnect(Connection conn)
                       throws PersistenceException
disconnects from DB, may return connection to pool if such exists any uncommited transactions are rolled back

connect

public static Connection connect(String connectURL,
                                 boolean usePool)
                          throws SQLException,
                                 ClassNotFoundException
connects to DB gets connection from pool if such exists

disconnect

public static void disconnect(Connection conn,
                              boolean usePool)
                       throws PersistenceException
disconnects from DB, may return connection to pool if such exists any uncommited transactions are rolled back

getSchemaPrefix

public static String getSchemaPrefix(String jdbcURL)

getDatabaseType

public static int getDatabaseType(String jdbcURL)