org.jhuapl.edu.sages.etl
Class SqlStateHandler
java.lang.Object
org.jhuapl.edu.sages.etl.SqlStateHandler
public class SqlStateHandler
- extends Object
Handles the various exceptions that result from SQL activity
- Author:
- POKUAM1
Method Summary |
int |
errorCleanup(SagesOpenCsvJar socj,
Savepoint savepoint,
Connection connection,
File currentCsv,
String failedDirPath,
Exception e)
error handling code. |
Set<String> |
getIgnorableErrorCodes()
|
protected boolean |
isSqlStateIgnorable(SQLException e)
|
void |
setIgnorableErrorCodes(Set<String> ignorableErrorCodes)
|
void |
sqlExceptionHandlerAlterCleanseTableAddFlagColumn(Connection c,
SagesOpenCsvJar socj,
Savepoint save1,
Savepoint createCleanseSavepoint,
Exception ex)
|
void |
sqlExceptionHandlerAlterStagingTableAddFlagColumn(Connection c,
SagesOpenCsvJar socj,
Savepoint save1,
Savepoint createCleanseSavepoint,
Exception ex)
|
void |
sqlExceptionHandlerBuildCleanseTable(Connection c,
SagesOpenCsvJar socj,
Savepoint save1,
Savepoint createCleanseSavepoint,
Exception ex)
|
void |
sqlExceptionHandlerBuildEtlStatusTable(Connection c,
SagesOpenCsvJar socj,
Savepoint save1,
Savepoint createEtlStatusSavepoint,
Exception ex)
|
void |
sqlExceptionHandlerBuildStagingTable(Connection c,
SagesOpenCsvJar socj,
Savepoint save1,
Savepoint createStagingSavepoint,
Exception ex)
|
void |
sqlExceptionHandlerTruncateCleanseAndStagingTables(DumbTestOpenCsvJar socj_dumb,
Connection c,
Savepoint baseLine,
Exception ex)
|
protected void |
sqlStateHandler(Connection c,
SagesOpenCsvJar socj,
Savepoint save1,
Savepoint lastSavepoint,
SQLException e,
String logMsg,
String fatalMsg)
SQL state handler examines the state code of sql exception and will
either:
catches a known error. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ignorableErrorCodes
protected Set<String> ignorableErrorCodes
- SQL codes that are safe to ignore and are expected
SqlStateHandler
public SqlStateHandler()
- default constructor
getIgnorableErrorCodes
public Set<String> getIgnorableErrorCodes()
setIgnorableErrorCodes
public void setIgnorableErrorCodes(Set<String> ignorableErrorCodes)
isSqlStateIgnorable
protected boolean isSqlStateIgnorable(SQLException e)
- Parameters:
e
- SQLException
- Returns:
- boolean if SQL state code is in the ignorable set of codes
sqlExceptionHandlerBuildCleanseTable
public void sqlExceptionHandlerBuildCleanseTable(Connection c,
SagesOpenCsvJar socj,
Savepoint save1,
Savepoint createCleanseSavepoint,
Exception ex)
throws SQLException,
SagesEtlException
- Parameters:
c
- - Connection
socj
- - SagesOpenCsvJar
save1
- - Savepoint
createCleanseSavepoint
- - Savepoint
- Throws:
SQLException
SagesEtlException
sqlExceptionHandlerBuildEtlStatusTable
public void sqlExceptionHandlerBuildEtlStatusTable(Connection c,
SagesOpenCsvJar socj,
Savepoint save1,
Savepoint createEtlStatusSavepoint,
Exception ex)
throws SQLException,
SagesEtlException
- Parameters:
c
- - Connection
socj
- - SagesOpenCsvJar
save1
- - Savepoint
createEtlStatusSavepoint
- - Savepoint
- Throws:
SQLException
SagesEtlException
sqlExceptionHandlerAlterCleanseTableAddFlagColumn
public void sqlExceptionHandlerAlterCleanseTableAddFlagColumn(Connection c,
SagesOpenCsvJar socj,
Savepoint save1,
Savepoint createCleanseSavepoint,
Exception ex)
throws SQLException,
SagesEtlException
- Parameters:
c
- - Connection
save1
- - Savepoint
createCleanseSavepoint
- - Savepoint
- Throws:
SQLException
SagesEtlException
sqlStateHandler
protected void sqlStateHandler(Connection c,
SagesOpenCsvJar socj,
Savepoint save1,
Savepoint lastSavepoint,
SQLException e,
String logMsg,
String fatalMsg)
throws SQLException
- SQL state handler examines the state code of sql exception and will
either:
catches a known error. we can ignore & recover.
or:
unknown error. bad. must abort.
- Parameters:
c
- - Connection
save1
- - Savepoint
lastSavepoint
- - Savepoint
the last savepoint corresponding to valid database integritye
- - SQLException
- Throws:
SQLException
sqlExceptionHandlerBuildStagingTable
public void sqlExceptionHandlerBuildStagingTable(Connection c,
SagesOpenCsvJar socj,
Savepoint save1,
Savepoint createStagingSavepoint,
Exception ex)
throws SQLException,
SagesEtlException
- Parameters:
c
- - Connection
socj
- - SagesOpenCsvJar
save1
- - Savepoint
createStagingSavepoint
- - Savepoint
- Throws:
SQLException
SagesEtlException
sqlExceptionHandlerAlterStagingTableAddFlagColumn
public void sqlExceptionHandlerAlterStagingTableAddFlagColumn(Connection c,
SagesOpenCsvJar socj,
Savepoint save1,
Savepoint createCleanseSavepoint,
Exception ex)
throws SQLException,
SagesEtlException
- Parameters:
c
- - Connection
save1
- - Savepoint
createCleanseSavepoint
- - Savepoint
- Throws:
SQLException
SagesEtlException
sqlExceptionHandlerTruncateCleanseAndStagingTables
public void sqlExceptionHandlerTruncateCleanseAndStagingTables(DumbTestOpenCsvJar socj_dumb,
Connection c,
Savepoint baseLine,
Exception ex)
throws SQLException,
SagesEtlException
- Parameters:
socj_dumb
- - DumbTestOpenCsvJar
c
- - Connection
baseLine
- - Savepoint
- Throws:
SQLException
SagesEtlException
errorCleanup
public int errorCleanup(SagesOpenCsvJar socj,
Savepoint savepoint,
Connection connection,
File currentCsv,
String failedDirPath,
Exception e)
- error handling code. transactions rollbacks, file moving/deletion
- Parameters:
socj
- SagesOpenCsvJar
the strategy belongs tosavepoint
- Savepoint
to rollback toconnection
- Connection
database connectioncurrentCsv
- File
file currently being processed by ETLfailedDirPath
- String
file directory to move failed filee
- Exception
exception that caused the error. used in logging output
- Returns:
Copyright © 2013 Johns Hopkins University Applied Physics Laboratory. All rights reserved.