| java.lang.Object com.flexive.core.Database
Database | final public class Database (Code) | | Class handling Database stuff
author: Gregor Schober (gregor.schober@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at) author: Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at) |
Method Summary | |
public static void | closeObjects(Class caller, Connection con, Statement stmt) Helper function to close connections and statements. | public static void | closeObjects(String caller, Connection con, Statement stmt) Helper function to close connections and statements. | public static DataSource | getDataSource() Returns the data source for the calling user's division. | public static DataSource | getDataSource(int divisionId) Retrieves a database connection. | public static Connection | getDbConnection(int divisionId) Retrieves a database connection. | public static Connection | getDbConnection() Return a database connection for the current user's division. | public static DivisionData | getDivisionData() | public static synchronized DataSource | getGlobalDataSource() Retrieve data source for global configuration table, regardless
of the current request's division id. | public static Connection | getGlobalDbConnection() Retrieves a database connection for the global configuration table, regardless
of the current request's division id. | public static boolean | isForeignKeyViolation(Exception exc) Returns true if the SqlError is a foreign key violation. | public static boolean | isUniqueConstraintViolation(Exception exc) Returns true if the SqlError is a unique constraint violation. | public static FxString | loadContentDataFxString(Connection con, String column, String whereClause) | public static FxString | loadFxString(Connection con, String table, String column, String whereClause) | public static FxString[] | loadFxString(Connection con, String table, String[] columns, String whereClause) | public static Map<Long, FxString[]> | loadFxStrings(Connection con, String table, String[] columns) Loads all FxString entries stored in the given table. | public static void | storeFxString(FxString string, Connection con, String table, String dataColumn, String idColumn, long id) | public static void | storeFxString(FxString[] string, Connection con, String table, String[] dataColumn, String idColumn, long id) |
MAX_DIVISIONS | final public static int MAX_DIVISIONS(Code) | | Maximum number of divisions
|
closeObjects | public static void closeObjects(Class caller, Connection con, Statement stmt)(Code) | | Helper function to close connections and statements.
A FxDbException is thrown if the close of the connection failed.
No Exception is thrown if the Statement failed to close, but a error is logged.
Parameters: caller - class calling function/module, or null Parameters: con - the connection to close, or null Parameters: stmt - the statement to close, or null |
closeObjects | public static void closeObjects(String caller, Connection con, Statement stmt)(Code) | | Helper function to close connections and statements.
A FxDbException is thrown if the close of the connection failed.
No Exception is thrown if the Statement failed to close, but a error is logged.
Parameters: caller - a string representing the calling function/module, or null Parameters: con - the connection to close, or null Parameters: stmt - the statement to close, or null |
getDataSource | public static DataSource getDataSource() throws SQLException(Code) | | Returns the data source for the calling user's division.
the data source for the calling user's division throws: SQLException - if a DB error occured |
getDataSource | public static DataSource getDataSource(int divisionId) throws SQLException(Code) | | Retrieves a database connection.
Parameters: divisionId - the division id a database connection throws: SQLException - If no connection could be retrieved |
getDbConnection | public static Connection getDbConnection(int divisionId) throws SQLException(Code) | | Retrieves a database connection.
Parameters: divisionId - the requested division Id a database connection throws: SQLException - If no connection could be retrieved |
getDbConnection | public static Connection getDbConnection() throws SQLException(Code) | | Return a database connection for the current user's division.
a database connection for the current user's division. throws: SQLException - if a DB error occured |
getGlobalDataSource | public static synchronized DataSource getGlobalDataSource() throws SQLException(Code) | | Retrieve data source for global configuration table, regardless
of the current request's division id.
a database connection throws: SQLException - if no connection could be retrieved |
getGlobalDbConnection | public static Connection getGlobalDbConnection() throws SQLException(Code) | | Retrieves a database connection for the global configuration table, regardless
of the current request's division id.
a database connection throws: SQLException - if no connection could be retrieved |
isForeignKeyViolation | public static boolean isForeignKeyViolation(Exception exc)(Code) | | Returns true if the SqlError is a foreign key violation.
Parameters: exc - the exception true if the SqlError is a foreign key violation |
isUniqueConstraintViolation | public static boolean isUniqueConstraintViolation(Exception exc)(Code) | | Returns true if the SqlError is a unique constraint violation.
Parameters: exc - the exception true if the SqlError is a unique constraint violation |
loadContentDataFxString | public static FxString loadContentDataFxString(Connection con, String column, String whereClause) throws SQLException(Code) | | Load a FxString from the content data
Parameters: con - an open connection Parameters: column - the name of the column from the translations table to load Parameters: whereClause - mandatory where clause FxString created from the data table throws: SQLException - if a database error occured |
loadFxString | public static FxString loadFxString(Connection con, String table, String column, String whereClause) throws SQLException(Code) | | Load a FxString from a translation table
Parameters: con - an open connection Parameters: table - the base table (NOT the one with translations!) Parameters: column - the name of the columns from the translations table to load Parameters: whereClause - mandatory where clause FxString created from the data table throws: SQLException - if a database error occured |
loadFxString | public static FxString[] loadFxString(Connection con, String table, String[] columns, String whereClause) throws SQLException(Code) | | Load an FxString array from multiple fields
Parameters: con - open and valid connection Parameters: table - table to use Parameters: columns - names of the columns containing the translations Parameters: whereClause - where clause for the table (like id=x) FxString array a string array representing columns throws: SQLException - if a database error occured |
loadFxStrings | public static Map<Long, FxString[]> loadFxStrings(Connection con, String table, String[] columns) throws SQLException(Code) | | Loads all FxString entries stored in the given table.
Parameters: con - an existing connection Parameters: table - table to use Parameters: columns - name of the columns containing the translations all FxString entries stored in the given table, indexed by the ID field. throws: SQLException - if the query was not successful |
storeFxString | public static void storeFxString(FxString string, Connection con, String table, String dataColumn, String idColumn, long id) throws SQLException(Code) | | Store a FxString in a translation table that only consists of one(!) translation column
Parameters: string - string to be stored Parameters: con - existing connection Parameters: table - storage table Parameters: dataColumn - name of the data column Parameters: idColumn - name of the id column Parameters: id - id of the given string throws: SQLException - if a database error occured |
storeFxString | public static void storeFxString(FxString[] string, Connection con, String table, String[] dataColumn, String idColumn, long id) throws SQLException(Code) | | Store a FxString in a translation table that only consists of n translation columns
Parameters: string - string to be stored Parameters: con - existing connection Parameters: table - storage table Parameters: dataColumn - names of the data columns Parameters: idColumn - name of the id column Parameters: id - id of the given string throws: SQLException - if a database error occured |
|
|