|
31 | 31 | import javax.sql.StatementEventListener; |
32 | 32 |
|
33 | 33 | import org.firebirdsql.gds.ng.LockCloseable; |
| 34 | +import org.firebirdsql.jaybird.xca.FatalErrorHelper; |
34 | 35 | import org.firebirdsql.jdbc.FBSQLException; |
35 | 36 | import org.firebirdsql.jdbc.SQLStateConstants; |
36 | 37 |
|
@@ -156,48 +157,14 @@ protected void fireFatalConnectionError(SQLException ex) { |
156 | 157 | protected void fireConnectionError(SQLException ex) { |
157 | 158 | SQLException currentException = ex; |
158 | 159 | while (currentException != null) { |
159 | | - String sqlState = currentException.getSQLState(); |
160 | | - if (isFatalState(sqlState)) { |
| 160 | + if (FatalErrorHelper.isFatal(currentException)) { |
161 | 161 | fireFatalConnectionError(ex); |
| 162 | + return; |
162 | 163 | } |
163 | 164 | currentException = ex.getNextException(); |
164 | 165 | } |
165 | 166 | } |
166 | 167 |
|
167 | | - /** |
168 | | - * Decides if the given SQL state is a fatal connection error. |
169 | | - * |
170 | | - * @param sqlState |
171 | | - * SQL State value |
172 | | - * @return <code>true</code> if the SQL state is considered fatal |
173 | | - */ |
174 | | - private boolean isFatalState(String sqlState) { |
175 | | - if (sqlState == null || sqlState.length() < 2) { |
176 | | - // No SQL State or no class specified, assume it's fatal |
177 | | - return true; |
178 | | - } |
179 | | - for (String fatalSqlStateClass : FATAL_SQL_STATE_CLASSES) { |
180 | | - if (sqlState.startsWith(fatalSqlStateClass)) { |
181 | | - return true; |
182 | | - } |
183 | | - } |
184 | | - return false; |
185 | | - } |
186 | | - |
187 | | - private static final String[] FATAL_SQL_STATE_CLASSES = { |
188 | | - // TODO double check firebird and Jaybird implementation for other states |
189 | | - "08", // Connection errors |
190 | | - "XX", // Internal errors |
191 | | - "01002", // Disconnect error |
192 | | - "01S00", // Invalid connection string attribute |
193 | | - "2D000", // Invalid transaction termination |
194 | | - "2E000", // Invalid connection name |
195 | | - "HY000", // General error (TODO: maybe too general?) |
196 | | - "HY001", // Memory allocation error |
197 | | - "HYT00", // Timeout expired |
198 | | - "HYT01", // Connection timeout expired |
199 | | - }; |
200 | | - |
201 | 168 | /** |
202 | 169 | * Helper method to fire the connectionClosed event. |
203 | 170 | */ |
|
0 commit comments