public class DataRepositoryImpl extends Object implements DataRepository
DataRepository.dbTypes| 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
|
static String |
SQLSERVER_CHECK_TABLE_QUERY
Field description
|
| Constructor and Description |
|---|
DataRepositoryImpl() |
| 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.
|
DataRepository.dbTypes |
getDatabaseType()
Returns type of DataRepository database
|
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)
Method description
|
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. |
public static final String DERBY_CONNVALID_QUERY
public static final String JDBC_CONNVALID_QUERY
public static final String MYSQL_CHECK_TABLE_QUERY
public static final String PGSQL_CHECK_TABLE_QUERY
public static final String DERBY_CHECK_TABLE_QUERY
public static final String SQLSERVER_CHECK_TABLE_QUERY
public static final String OTHER_CHECK_TABLE_QUERY
public static final String SP_STARTS_WITH
public static final String QUERY_TIMEOUT_PROP_KEY
public static final int QUERY_TIMEOUT
public static final String DB_CONN_TIMEOUT_PROP_KEY
public static final int DB_CONN_TIMEOUT
public boolean checkTable(String tableName) throws SQLException
checkTable in interface DataRepositorytableName - true boolean value if the table exist in
the database and false if the table was not found.SQLExceptionpublic boolean checkTable(String tableName, String createTableQuery) throws SQLException
DataRepositorycheckTable in interface DataRepositorytableName - is a String value of the table name to checkcreateTableQuery - is a String with the query to create tabletrue boolean value if the table exist in
the database and false if the table was not found.SQLException - if there was a problem accessing database.public Statement createStatement(tigase.xmpp.BareJID user_id) throws SQLException
createStatement in interface DataRepositoryuser_id - user id for which the statement has to be created. This is an
optional parameter and null can be provided. It is used mainly to group queries
for the same user on the same DB connection.StatementSQLExceptionpublic PreparedStatement getPreparedStatement(tigase.xmpp.BareJID user_id, String stIdKey) throws SQLException
getPreparedStatement in interface DataRepositorystIdKey - user_id - user id for which the statement has to be created. This is
an optional parameter and null can be provided. It is used mainly to group
queries for the same user on the same DB connection.PreparedStatement for the given id key or null if
such a statement does not exist.SQLExceptionpublic String getResourceUri()
getResourceUri in interface DataRepositoryString value representing database connection
string.public DataRepository.dbTypes getDatabaseType()
DataRepositorygetDatabaseType in interface DataRepositorydbTypespublic void initPreparedStatement(String key, String query) throws SQLException
initPreparedStatement in interface DataRepositorykey - query - SQLExceptionpublic void initRepository(String resource_uri, Map<String,String> params) throws SQLException
initRepository in interface DataRepositoryresource_uri - params - SQLExceptionpublic void release(Statement stmt, ResultSet rs)
release in interface DataRepositorystmt - rs - public DataRepository takeRepoHandle(tigase.xmpp.BareJID user_id)
DataRepositoryDataRepository 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.takeRepoHandle in interface DataRepositoryuser_id - is user account ID for which we acquire the handle.public void startTransaction()
throws SQLException
DataRepositorystartTransaction in interface DataRepositorySQLExceptionpublic void commit()
throws SQLException
DataRepositorycommit in interface DataRepositorySQLExceptionpublic void rollback()
throws SQLException
DataRepositoryrollback in interface DataRepositorySQLExceptionpublic void endTransaction()
throws SQLException
DataRepositoryendTransaction in interface DataRepositorySQLExceptionpublic void releaseRepoHandle(DataRepository repo)
DataRepositoryreleaseRepoHandle in interface DataRepositoryrepo - is a DataRepositoryCopyright © 2013 Tigase. All rights reserved.