Skip to content

Commit 4e7e2e3

Browse files
committed
#899 Backport to Jaybird 5: usage of FatalErrorHelper in FBPooledConnection
1 parent 06b3f4f commit 4e7e2e3

2 files changed

Lines changed: 10 additions & 36 deletions

File tree

src/docs/asciidoc/release_notes.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ Changes per Jaybird 5 release.
2929
See also <<whats-new-in-jaybird-5>>.
3030
For known issues, consult <<known-issues>>.
3131

32+
[#jaybird-5-0-11-changelog]
33+
=== Jaybird 5.0.11
34+
35+
The following has been changed or fixed since Jaybird 5.0.10:
36+
37+
* Backported fatal error detection improvements for `FBPooledConnection` from Jaybird 6 (https://github.com/FirebirdSQL/jaybird/issues/899[#899])
38+
3239
[#jaybird-5-0-10-changelog]
3340
=== Jaybird 5.0.10
3441

src/main/org/firebirdsql/ds/FBPooledConnection.java

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import javax.sql.StatementEventListener;
3232

3333
import org.firebirdsql.gds.ng.LockCloseable;
34+
import org.firebirdsql.jaybird.xca.FatalErrorHelper;
3435
import org.firebirdsql.jdbc.FBSQLException;
3536
import org.firebirdsql.jdbc.SQLStateConstants;
3637

@@ -156,48 +157,14 @@ protected void fireFatalConnectionError(SQLException ex) {
156157
protected void fireConnectionError(SQLException ex) {
157158
SQLException currentException = ex;
158159
while (currentException != null) {
159-
String sqlState = currentException.getSQLState();
160-
if (isFatalState(sqlState)) {
160+
if (FatalErrorHelper.isFatal(currentException)) {
161161
fireFatalConnectionError(ex);
162+
return;
162163
}
163164
currentException = ex.getNextException();
164165
}
165166
}
166167

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-
201168
/**
202169
* Helper method to fire the connectionClosed event.
203170
*/

0 commit comments

Comments
 (0)