public interface DataRepository extends DataSource
Modifier and Type | Interface and Description |
---|---|
static class |
DataRepository.dbTypes
Helper enumeration with types of supported databases.
|
Repository.Meta, Repository.SchemaId
Modifier and Type | Field and Description |
---|---|
static Calendar |
UTC_CALENDAR |
log
Modifier and Type | Method and Description |
---|---|
boolean |
checkTable(String tableName)
The method checks whether a table for the given name exists in the database.
|
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(BareJID user_id)
Creates a SQL statement on which SQL queries can be executed later by the higher repository layer.
|
void |
endTransaction()
Ends current transaction on the DataRepository connection.
|
DataRepository.dbTypes |
getDatabaseType()
Returns type of DataRepository database
|
int |
getPoolSize() |
PreparedStatement |
getPreparedStatement(BareJID user_id,
String stIdKey)
Returns a prepared statement for a given key.
|
PreparedStatement |
getPreparedStatement(int hashCode,
String stIdKey)
Returns a prepared statement for a given key.
|
String |
getResourceUri()
Returns a DB connection string or DB connection URI.
|
default Timestamp |
getTimestamp(ResultSet rs,
int pos)
Helper method to get timestamp from result set.
|
default Timestamp |
getTimestamp(ResultSet rs,
String field)
Helper method to get timestamp from result set.
|
void |
initPreparedStatement(String stIdKey,
String query)
Initializes a prepared statement for a given query and stores it internally under the given id key.
|
void |
initPreparedStatement(String stIdKey,
String query,
int autoGeneratedKeys)
Initializes a prepared statement for a given query and stores it internally under the given id key.
|
void |
release(Statement stmt,
ResultSet rs)
A helper method to release resources from the statement and result set.
|
void |
releaseRepoHandle(DataRepository repo) |
void |
rollback()
Rolls back started transaction on the DataRepository connection.
|
default void |
setTimestamp(PreparedStatement stmt,
int pos,
Timestamp timestamp)
Helper method to set timestamp into prepared statements.
|
void |
startTransaction()
Starts transaction on the DataRepository connection.
|
DataRepository |
takeRepoHandle(BareJID user_id)
Returns
DataRepository instance. |
automaticSchemaManagement, checkConnectivity, checkSchemaVersion, getSchemaVersion, initialize
initRepository
static final Calendar UTC_CALENDAR
boolean checkTable(String tableName) throws SQLException
tableName
- is a String
value of the table name to checktrue
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.boolean checkTable(String tableName, String createTableQuery) throws SQLException
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.void commit() throws SQLException
SQLException
Statement createStatement(BareJID user_id) throws SQLException
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
- if a JDBC error occurs.void endTransaction() throws SQLException
SQLException
void initPreparedStatement(String stIdKey, String query) throws SQLException
getPreparedStatement(stIdKey)
method.stIdKey
- is a statement identification key.query
- is a query for the prepared statement.SQLException
void initPreparedStatement(String stIdKey, String query, int autoGeneratedKeys) throws SQLException
getPreparedStatement(stIdKey)
method.stIdKey
- is a statement identification key.query
- is a query for the prepared statement.autoGeneratedKeys
- defines if statement should return auto generated keysSQLException
void release(Statement stmt, ResultSet rs)
stmt
- a Statement
variable to release resources for. Might be null.rs
- a ResultSet
variable to release resources for. Might be null.void releaseRepoHandle(DataRepository repo)
void rollback() throws SQLException
SQLException
void startTransaction() throws SQLException
SQLException
DataRepository takeRepoHandle(BareJID user_id)
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.user_id
- is user account ID for which we acquire the handle.DataRepository.dbTypes getDatabaseType()
dbTypes
int getPoolSize()
PreparedStatement getPreparedStatement(BareJID user_id, String stIdKey) throws SQLException
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.stIdKey
- is a statement identification key.PreparedStatement
for the given id key or null if such a statement does not exist.SQLException
PreparedStatement getPreparedStatement(int hashCode, String stIdKey) throws SQLException
hashCode
- user for selection of connection to use. It is used mainly to group queries for the same user on
the same DB connection.stIdKey
- is a statement identification key.PreparedStatement
for the given id key or null if such a statement does not exist.SQLException
String getResourceUri()
getResourceUri
in interface DataSource
String
value representing database connection string.default void setTimestamp(PreparedStatement stmt, int pos, Timestamp timestamp) throws SQLException
SQLException
default Timestamp getTimestamp(ResultSet rs, int pos) throws SQLException
SQLException
default Timestamp getTimestamp(ResultSet rs, String field) throws SQLException
SQLException
Copyright © 2004–2020 "Tigase, Inc.". All rights reserved.