Class DBCommonOperations
- java.lang.Object
-
- com.h2tcoin.takamakachain.db.embedded.DBCommonOperations
-
public class DBCommonOperations extends Object
- Author:
- iris.dimni
-
-
Constructor Summary
Constructors Constructor Description DBCommonOperations()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static voidcloseStatement(Statement stm)protected static intcountElementExistHS(Connection conn, String table, String column, String value)Counter function LIMITED to 1 max.protected static intcountFromTable(Connection conn, String table, String column, String value)protected static voidcreateSingleColumnIndexASCIfNotExist(Connection conn, String tableName, String column)protected static voidcreateSingleColumnIndexDESCIfNotExist(Connection conn, String tableName, String column)protected static voidcreateSingleColumnIndexIfNotExist(Connection conn, String tableName, String column)CREATE single column generic index for tableprotected static voidcreateTableIndexIfNoneExist(Connection conn, String tableName, String column)duplicate code replace with create single column indexprotected static voidcreateTableIndexIfNoneExist(Connection conn, Statement statement, String tableName, String column)duplicate code replace with create single column indexprotected static longdeleteFromTable(Connection conn, String table, String column, String value)protected static intgetTableRows(Connection conn, Statement stm, String table)Returns the number of rows of a given tableprotected static voidmoveToTemporaryTable(Connection conn, String table)clone existing table to temporary one and create a new empty idetical table in place of the moved oneprotected static voidrestoreFromTemporaryTable(Connection conn, String table)drop current tabletablean move older table in place.protected static ResultSetselectFromTable(Connection conn, String table, String column, String value)generic selectprotected static PreparedStatementselectGenericStatementStringTable(Connection conn, String table, String column, String value)protected static voidtruncateTable(Connection conn, String table)does a truncate of the indicated table
-
-
-
Method Detail
-
createSingleColumnIndexIfNotExist
protected static void createSingleColumnIndexIfNotExist(Connection conn, String tableName, String column)
CREATE single column generic index for table- Parameters:
conn-tableName-column-
-
createSingleColumnIndexASCIfNotExist
protected static void createSingleColumnIndexASCIfNotExist(Connection conn, String tableName, String column)
-
createSingleColumnIndexDESCIfNotExist
protected static void createSingleColumnIndexDESCIfNotExist(Connection conn, String tableName, String column)
-
truncateTable
protected static void truncateTable(Connection conn, String table)
does a truncate of the indicated table- Parameters:
conn-table-
-
getTableRows
protected static int getTableRows(Connection conn, Statement stm, String table)
Returns the number of rows of a given table- Parameters:
conn-stm-table-- Returns:
-
createTableIndexIfNoneExist
protected static void createTableIndexIfNoneExist(Connection conn, String tableName, String column)
duplicate code replace with create single column index- Parameters:
conn-tableName-column-
-
createTableIndexIfNoneExist
protected static void createTableIndexIfNoneExist(Connection conn, Statement statement, String tableName, String column)
duplicate code replace with create single column index- Parameters:
conn-statement-tableName-column-
-
deleteFromTable
protected static long deleteFromTable(Connection conn, String table, String column, String value)
-
selectFromTable
protected static ResultSet selectFromTable(Connection conn, String table, String column, String value)
generic select- Parameters:
conn-table-column-value-- Returns:
-
selectGenericStatementStringTable
protected static PreparedStatement selectGenericStatementStringTable(Connection conn, String table, String column, String value)
-
countElementExistHS
protected static int countElementExistHS(Connection conn, String table, String column, String value) throws SQLException
Counter function LIMITED to 1 max. Used for checking existence.- Parameters:
conn-table-column-value-- Returns:
- 1 if at least 1 elemnt matcing serch criteria is found. 0 otherwise
- Throws:
SQLException
-
countFromTable
protected static int countFromTable(Connection conn, String table, String column, String value) throws SQLException
- Throws:
SQLException
-
moveToTemporaryTable
protected static void moveToTemporaryTable(Connection conn, String table) throws SQLException
clone existing table to temporary one and create a new empty idetical table in place of the moved one- Parameters:
conn-table-- Throws:
SQLException
-
restoreFromTemporaryTable
protected static void restoreFromTemporaryTable(Connection conn, String table) throws SQLException
drop current tabletablean move older table in place. Must be called aftermoveToTemporaryTable- Parameters:
conn-table-- Throws:
SQLException
-
closeStatement
protected static void closeStatement(Statement stm)
-
-