public class DataRepositoryPool extends Object implements DataRepository
DataRepository.dbTypes
Repository.Meta
Constructor and Description |
---|
DataRepositoryPool() |
Modifier and Type | Method and Description |
---|---|
void |
addRepo(DataRepository repo)
Method 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
|
PreparedStatement |
getPreparedStatement(tigase.xmpp.BareJID user_id,
String stIdKey)
Method description
|
String |
getResourceUri()
Method description
|
void |
initPreparedStatement(String stIdKey,
String query)
Method description
|
void |
initPreparedStatement(String stIdKey,
String query,
int autoGeneratedKeys)
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 |
takeRepo(tigase.xmpp.BareJID user_id)
Method description
|
DataRepository |
takeRepoHandle(tigase.xmpp.BareJID user_id)
Returns
DataRepository instance. |
public void addRepo(DataRepository repo)
repo
- public DataRepository takeRepo(tigase.xmpp.BareJID user_id)
public DataRepository takeRepoHandle(tigase.xmpp.BareJID user_id)
DataRepository
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.takeRepoHandle
in interface DataRepository
user_id
- is user account ID for which we acquire the handle.public void releaseRepoHandle(DataRepository repo)
DataRepository
releaseRepoHandle
in interface DataRepository
repo
- is a DataRepository
public boolean checkTable(String tableName) throws SQLException
checkTable
in interface DataRepository
tableName
- true
boolean
value if the table exist in
the database and false
if the table was not found.SQLException
public boolean checkTable(String tableName, String createTableQuery) throws SQLException
DataRepository
checkTable
in interface DataRepository
tableName
- 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 DataRepository
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.Statement
SQLException
public PreparedStatement getPreparedStatement(tigase.xmpp.BareJID user_id, String stIdKey) throws SQLException
getPreparedStatement
in interface DataRepository
stIdKey
- 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.SQLException
public String getResourceUri()
getResourceUri
in interface DataRepository
String
value representing database connection
string.public DataRepository.dbTypes getDatabaseType()
DataRepository
getDatabaseType
in interface DataRepository
dbTypes
public void initPreparedStatement(String stIdKey, String query) throws SQLException
initPreparedStatement
in interface DataRepository
stIdKey
- query
- SQLException
public void initPreparedStatement(String stIdKey, String query, int autoGeneratedKeys) throws SQLException
initPreparedStatement
in interface DataRepository
stIdKey
- query
- autoGeneratedKeys
- defines if statement should return auto generated keysSQLException
public void initRepository(String resource_uri, Map<String,String> params) throws DBInitException
initRepository
in interface Repository
resource_uri
- params
- SQLException
DBInitException
- if there was an error during repository initialization.
Some implementations, though, perform so called lazy initialization so even though there
is a problem with the underlying repository it may not be signaled through this method
call.public void release(Statement stmt, ResultSet rs)
release
in interface DataRepository
stmt
- rs
- public void startTransaction() throws SQLException
DataRepository
startTransaction
in interface DataRepository
SQLException
public void commit() throws SQLException
DataRepository
commit
in interface DataRepository
SQLException
public void rollback() throws SQLException
DataRepository
rollback
in interface DataRepository
SQLException
public void endTransaction() throws SQLException
DataRepository
endTransaction
in interface DataRepository
SQLException
Copyright © 2014 "Tigase, Inc.". All rights reserved.