1 16 17 package org.springframework.jdbc.support; 18 19 import org.springframework.util.StringUtils; 20 21 34 public class SQLErrorCodes { 35 36 private String [] databaseProductNames; 37 38 private boolean useSqlStateForTranslation = false; 39 40 private String [] badSqlGrammarCodes = new String [0]; 41 42 private String [] invalidResultSetAccessCodes = new String [0]; 43 44 private String [] dataAccessResourceFailureCodes = new String [0]; 45 46 private String [] permissionDeniedCodes = new String [0]; 47 48 private String [] dataIntegrityViolationCodes = new String [0]; 49 50 private String [] cannotAcquireLockCodes = new String [0]; 51 52 private String [] deadlockLoserCodes = new String [0]; 53 54 private String [] cannotSerializeTransactionCodes = new String [0]; 55 56 private CustomSQLErrorCodesTranslation[] customTranslations; 57 58 59 63 public void setDatabaseProductName(String databaseProductName) { 64 this.databaseProductNames = new String [] {databaseProductName}; 65 } 66 67 public String getDatabaseProductName() { 68 return (this.databaseProductNames != null && this.databaseProductNames.length > 0 ? 69 this.databaseProductNames[0] : null); 70 } 71 72 76 public void setDatabaseProductNames(String [] databaseProductNames) { 77 this.databaseProductNames = databaseProductNames; 78 } 79 80 public String [] getDatabaseProductNames() { 81 return databaseProductNames; 82 } 83 84 88 public void setUseSqlStateForTranslation(boolean useStateCodeForTranslation) { 89 this.useSqlStateForTranslation = useStateCodeForTranslation; 90 } 91 92 public boolean isUseSqlStateForTranslation() { 93 return useSqlStateForTranslation; 94 } 95 96 97 public void setBadSqlGrammarCodes(String [] badSqlGrammarCodes) { 98 this.badSqlGrammarCodes = StringUtils.sortStringArray(badSqlGrammarCodes); 99 } 100 101 public String [] getBadSqlGrammarCodes() { 102 return badSqlGrammarCodes; 103 } 104 105 public void setInvalidResultSetAccessCodes(String [] invalidResultSetAccessCodes) { 106 this.invalidResultSetAccessCodes = invalidResultSetAccessCodes; 107 } 108 109 public String [] getInvalidResultSetAccessCodes() { 110 return invalidResultSetAccessCodes; 111 } 112 113 public void setDataAccessResourceFailureCodes(String [] dataAccessResourceFailureCodes) { 114 this.dataAccessResourceFailureCodes = dataAccessResourceFailureCodes; 115 } 116 117 public String [] getDataAccessResourceFailureCodes() { 118 return dataAccessResourceFailureCodes; 119 } 120 121 public void setPermissionDeniedCodes(String [] permissionDeniedCodes) { 122 this.permissionDeniedCodes = StringUtils.sortStringArray(permissionDeniedCodes); 123 } 124 125 public String [] getPermissionDeniedCodes() { 126 return permissionDeniedCodes; 127 } 128 129 public void setDataIntegrityViolationCodes(String [] dataIntegrityViolationCodes) { 130 this.dataIntegrityViolationCodes = StringUtils.sortStringArray(dataIntegrityViolationCodes); 131 } 132 133 public String [] getDataIntegrityViolationCodes() { 134 return dataIntegrityViolationCodes; 135 } 136 137 public void setCannotAcquireLockCodes(String [] cannotAcquireLockCodes) { 138 this.cannotAcquireLockCodes = StringUtils.sortStringArray(cannotAcquireLockCodes); 139 } 140 141 public String [] getCannotAcquireLockCodes() { 142 return cannotAcquireLockCodes; 143 } 144 145 public void setDeadlockLoserCodes(String [] deadlockLoserCodes) { 146 this.deadlockLoserCodes = deadlockLoserCodes; 147 } 148 149 public String [] getDeadlockLoserCodes() { 150 return deadlockLoserCodes; 151 } 152 153 public void setCannotSerializeTransactionCodes(String [] cannotSerializeTransactionCodes) { 154 this.cannotSerializeTransactionCodes = cannotSerializeTransactionCodes; 155 } 156 157 public String [] getCannotSerializeTransactionCodes() { 158 return cannotSerializeTransactionCodes; 159 } 160 161 public void setCustomTranslations(CustomSQLErrorCodesTranslation[] customTranslations) { 162 this.customTranslations = customTranslations; 163 } 164 165 public CustomSQLErrorCodesTranslation[] getCustomTranslations() { 166 return customTranslations; 167 } 168 169 } 170 | Popular Tags |