Fields Summary |
---|
private static final Logger | logger |
private static final String | SYSTEM_PROPERTY |
public boolean | traceOn |
private static final String | TABLE_EXISTS_SQL_ERROR_CODE |
Connection | con |
String | tableName |
private static final String | DEFAULT_SERVER_NAME |
private long | totalEntriesProcessed |
private String | name |
private static final String | INVALID_TABLE_NAME_CHARACTER_DASH |
private static final String | INVALID_TABLE_NAME_CHARACTER_DOT |
private static final String | INVALID_TABLE_NAME_REPLACEMENT_STRING |
private static final String | OVERRIDE_DEFAULT_REPLACEMENT_STRING |
Methods Summary |
---|
public void | addTotalEntriesProcessed(int totalEntriesProcessed)
this.totalEntriesProcessed += totalEntriesProcessed;
|
boolean | createStatmentAndExecuteUpdate(java.lang.String oldsql, java.lang.String tableNameWithoutServerInstance)
String sql = updateSqlWithTableName (oldsql, tableNameWithoutServerInstance);
boolean result = false;
Statement stmt = null;
try{
if (con != null){
stmt = con.createStatement();
stmt.executeUpdate(sql);
result = true;
}
} catch (java.sql.SQLException se) {
// log it
logger.log(Level.WARNING, "Error accessing CallFlow tables!", se);
result = false;
} finally {
if(stmt != null){
try{
stmt.close();
}catch(java.sql.SQLException s){
// log it
}
}
stmt = null;
}
return result;
|
public abstract boolean | createTable(java.sql.Connection connection)
|
boolean | createTable(java.lang.String oldsql, java.lang.String tableNameWithoutServerInstance)This method is used to create a database table. If the table already
exists, it logs a message and returns successfully.
As there is no mechanism to actually test if the database exists, it creates
the table and if there is an exception, it assumes it is due to table
being present.
String sql = updateSqlWithTableName (oldsql, tableNameWithoutServerInstance);
boolean result = false;
Statement stmt = null;
try{
if (con != null){
stmt = con.createStatement();
stmt.executeUpdate(sql);
result = true;
}
} catch (java.sql.SQLException se) {
// log it
if (se.getSQLState().equalsIgnoreCase (TABLE_EXISTS_SQL_ERROR_CODE)){
logger.log (Level.FINE, "callflow.table_already_exists_error",
tableNameWithoutServerInstance);
} else {
logger.log(Level.WARNING, "callflow.table_creation_error",
tableNameWithoutServerInstance);
logger.log(Level.WARNING, "callflow.table_creation_error", se);
}
result = true;
} finally {
if(stmt != null){
try{
stmt.close();
}catch(java.sql.SQLException s){
// log it
}
}
stmt = null;
}
return result;
|
public boolean | delete(java.sql.PreparedStatement pstmt, java.lang.String[] requestId)
if (pstmt == null)
return false;
boolean result = false;
try{
for (int i = 0 ; i<requestId.length; i++) {
pstmt.setString(1, requestId[i]);
pstmt.addBatch();
}
int[] updated = pstmt.executeBatch();
result = (updated.length == requestId.length)? true : false;
if (result == false){
logger.log (Level.WARNING, "callflow.error_delete_row");
}
} catch(BatchUpdateException bue) {
// log it
logger.log (Level.WARNING, "callflow.error_delete_row");
logger.log(Level.FINE, "Error data into CallFlow tables", bue);
result = false;
}catch (SQLException se) {
// log it
logger.log (Level.WARNING, "callflow.error_delete_row");
logger.log(Level.FINE, "Error inserting data into CallFlow tables", se);
result = false;
}
return result;
|
public abstract boolean | dropTable(java.sql.Connection connection)
|
public java.lang.String | getName()
return name;
|
public java.lang.String | getServerInstanceName()
// get the server name from config
String server = DEFAULT_SERVER_NAME;
ServerContext sc = ApplicationServer.getServerContext();
if (sc != null) {
server = removeInvalidCharactersFromTableName(sc.getInstanceName());
}
return "__" + server;
|
public long | getTotalEntriesProcessed()
return totalEntriesProcessed;
|
public boolean | isTraceOn()
return traceOn;
|
public java.lang.String | removeInvalidCharactersFromTableName(java.lang.String instanceName)
String overrideString = null;
overrideString = System.getProperty(OVERRIDE_DEFAULT_REPLACEMENT_STRING);
if (overrideString == null){
overrideString = this.INVALID_TABLE_NAME_REPLACEMENT_STRING;
}
String tmp = instanceName.replace(INVALID_TABLE_NAME_CHARACTER_DOT, overrideString);
String modifiedInstanceName = tmp.replace (INVALID_TABLE_NAME_CHARACTER_DASH,
overrideString);
return modifiedInstanceName;
|
public void | setName(java.lang.String name)
this.name = name;
|
java.lang.String | updateSqlWithTableName(java.lang.String oldsql, java.lang.String table)Adds the server instance name to the table names in the SQL statements
for create/delete and insert. All creates and deletes need to call them
before they submit the query to be executed
String newsql = new String(oldsql);
newsql = newsql.replaceAll(table, tableName);
return newsql;
|