Class SQLCodes

java.lang.Object
com.softwaremining.sql.SQLCodes

public class SQLCodes extends Object
Class used internally by SoftwareMining framework to load "optional" sqlcodes.properties configuration file
This provides a map of return-codes from original database to a new Database.
The purpose is to help database migrations for applications using EXEC SQL (ESQL) form of database access. ESQL application will have hard-coded Database-specific SQL-CODES in the application.
For example, a DB2 application may contain:
       EXEC SQL      INSERT INTO TABLE-1 ....    END-EXEC.
  * CHECK IF Record already exists - SQL Code is -803 
       IF SQLCODE = -803 ....
 
In above example, DB2 will assign an SQLCODE of -803 if there was a duplicate record. But when moving to another database such as ORACLE, the database may assign a different value (1 ) to represent DUPLICATE RECORD.
This class, and the associated sqlcodes.properties provides a means of substituting the values , e.g. changing Sql code of 1 to -803 in above example. In this approach the substitutions are done in the framework libraries, and avoids changes to the generated code.
for this example, the following entries should be entered into sqlcodes.properties file:
 
   -803=1
   -530=-2291
   -516=-1002
 ...
 

The system defaults to DB2 codes for new/old when sqlcodes.properties is missing
For further information please see DB2 codes
Oracle codes
Mysql codes
  • Constructor Details

    • SQLCodes

      public SQLCodes()
  • Method Details

    • getPropertyAsInt

      protected static int getPropertyAsInt(Properties props, String propertyName, int defaultValue)
    • translateSQLErrorCodes

      public static int translateSQLErrorCodes(SQLException e, int rowCount, boolean afterEndOfResultSet)
    • getCURRENT_DB_DUPLICATE_INSERT

      public static int getCURRENT_DB_DUPLICATE_INSERT()
    • getORIG_DB_NORMAL_RETURN

      public static int getORIG_DB_NORMAL_RETURN()