SQLErrorCodes based on the
"databaseProductName" taken from the java.sql.DatabaseMetaData .
Returns SQLErrorCodes populated with vendor codes
defined in a configuration file named "sql-error-codes.xml".
Reads the default file in this package if not overridden by a file in
the root of the class path (for example in the "/WEB-INF/classes" directory).
java.sql.DatabaseMetaData#getDatabaseProductName()
| Modifier and Type | Field and Description |
|---|---|
| private final Map | dataSourceCache
Map to cache the SQLErrorCodes instance per DataSource. |
| private final Map | errorCodesMap
Map to hold error codes for all databases defined in the config file. |
| private static SQLErrorCodesFactory | instance
Keep track of a single instance so we can return it to classes that request it. |
| private static final Log | |
| public static final String | SQL_ERROR_CODE_DEFAULT_PATH
The name of default SQL error code files, loading from the class path. |
| public static final String | SQL_ERROR_CODE_OVERRIDE_PATH
The name of custom SQL error codes file, loading from the root of the class path (e.g. from the "/WEB-INF/classes" directory). |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| private void | checkCustomTranslatorRegistry(String databaseName, SQLErrorCodes errorCodes)
Check the |
| public SQLErrorCodes | Returns: theSQLErrorCodes instance for the given database
(never null; potentially empty)the database name (must not be databaseName)null)Return the |
| public SQLErrorCodes | Returns: the correspondingSQLErrorCodes object
(never null; potentially empty)the dataSource)DataSource identifying the databaseReturn |
| public static SQLErrorCodesFactory | |
| private String | Returns: the identification Stringthe dataSource)DataSource to introspectBuild an identification String for the given |
| protected Resource | Returns: the resource, ornull if the resource wasn't foundresource path; either a custom path or one of either
path)SQL_ERROR_CODE_DEFAULT_PATH or
SQL_ERROR_CODE_OVERRIDE_PATH.Load the given resource from the class path. |
| public SQLErrorCodes | Returns: the correspondingSQLErrorCodes object (never null)the dataSource, String DataSource identifying the databasethe corresponding database name as stated in the error codes
definition file (must not be databaseName)null)Associate the specified database name with the given |
| public SQLErrorCodes | Returns: the correspondingSQLErrorCodes object,
or null in case of a JDBC meta-data access problemthe dataSource)DataSource identifying the databaseReturn |
| public SQLErrorCodes | Returns: the correspondingSQLErrorCodes object that got removed,
or null if not registeredthe dataSource)DataSource identifying the databaseClear the cache for the specified |
| dataSourceCache | back to summary |
|---|---|
| private final Map<DataSource, SQLErrorCodes> dataSourceCache Map to cache the SQLErrorCodes instance per DataSource. | |
| errorCodesMap | back to summary |
|---|---|
| private final Map<String, SQLErrorCodes> errorCodesMap Map to hold error codes for all databases defined in the config file. Key is the database product name, value is the SQLErrorCodes instance. | |
| instance | back to summary |
|---|---|
| private static SQLErrorCodesFactory instance Keep track of a single instance so we can return it to classes that request it.
Lazily initialized in order to avoid making | |
| logger | back to summary |
|---|---|
| private static final Log logger | |
| SQL_ERROR_CODE_DEFAULT_PATH | back to summary |
|---|---|
| public static final String SQL_ERROR_CODE_DEFAULT_PATH The name of default SQL error code files, loading from the class path. | |
| SQL_ERROR_CODE_OVERRIDE_PATH | back to summary |
|---|---|
| public static final String SQL_ERROR_CODE_OVERRIDE_PATH The name of custom SQL error codes file, loading from the root of the class path (e.g. from the "/WEB-INF/classes" directory). | |
| SQLErrorCodesFactory | back to summary |
|---|---|
| protected SQLErrorCodesFactory() Create a new instance of the Not public to enforce Singleton design pattern. Would be private
except to allow testing via overriding the
Do not subclass in application code.
| |
| checkCustomTranslatorRegistry | back to summary |
|---|---|
| private void checkCustomTranslatorRegistry(String databaseName, SQLErrorCodes errorCodes) Check the | |
| getErrorCodes | back to summary |
|---|---|
| public SQLErrorCodes getErrorCodes(String databaseName) Return the No need for a database meta-data lookup.
| |
| getErrorCodes | back to summary |
|---|---|
| public SQLErrorCodes getErrorCodes(DataSource dataSource) Return
| |
| getInstance | back to summary |
|---|---|
| public static SQLErrorCodesFactory getInstance() Return the singleton instance. | |
| identify | back to summary |
|---|---|
| private String identify(DataSource dataSource) Build an identification String for the given
| |
| loadResource | back to summary |
|---|---|
| protected Resource loadResource(String path) Load the given resource from the class path. Not to be overridden by application developers, who should obtain
instances of this class from the static Protected for testability.
| |
| registerDatabase | back to summary |
|---|---|
| public SQLErrorCodes registerDatabase(DataSource dataSource, String databaseName) Associate the specified database name with the given
| |
| resolveErrorCodes | back to summary |
|---|---|
| public SQLErrorCodes resolveErrorCodes(DataSource dataSource) Return
| |
| unregisterDatabase | back to summary |
|---|---|
| public SQLErrorCodes unregisterDatabase(DataSource dataSource) Clear the cache for the specified
| |