Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
9e29b32e
Commit
9e29b32e
authored
22 years ago
by
Dave Cramer
Browse files
Options
Downloads
Patches
Plain Diff
patch to notify listeners on error from Csaba Nagy
parent
f1792b93
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/interfaces/jdbc/org/postgresql/jdbc2/optional/PooledConnectionImpl.java
+32
-17
32 additions, 17 deletions
...c/org/postgresql/jdbc2/optional/PooledConnectionImpl.java
with
32 additions
and
17 deletions
src/interfaces/jdbc/org/postgresql/jdbc2/optional/PooledConnectionImpl.java
+
32
−
17
View file @
9e29b32e
...
...
@@ -13,7 +13,8 @@ import org.postgresql.PGConnection;
* @see ConnectionPool
*
* @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.6 $
* @author Csaba Nagy (ncsaba@yahoo.com)
* @version $Revision: 1.7 $
*/
public
class
PooledConnectionImpl
implements
PooledConnection
{
...
...
@@ -95,33 +96,47 @@ public class PooledConnectionImpl implements PooledConnection
{
if
(
con
==
null
)
{
throw
new
SQLException
(
"This PooledConnection has already been closed!"
);
// Before throwing the exception, let's notify the registered listeners about the error
final
SQLException
sqlException
=
new
SQLException
(
"This PooledConnection has already been closed!"
);
fireConnectionFatalError
(
sqlException
);
throw
sqlException
;
}
// Only one connection can be open at a time from this PooledConnection. See JDBC 2.0 Optional Package spec section 6.2.3
if
(
last
!=
null
)
// If any error occures while opening a new connection, the listeners
// have to be notified. This gives a chance to connection pools to
// elliminate bad pooled connections.
try
{
last
.
close
();
if
(
!
con
.
getAutoCommit
()
)
// Only one connection can be open at a time from this PooledConnection. See JDBC 2.0 Optional Package spec section 6.2.3
if
(
last
!=
null
)
{
try
last
.
close
();
if
(!
con
.
getAutoCommit
())
{
con
.
rollback
();
try
{
con
.
rollback
();
}
catch
(
SQLException
e
)
{}
}
catch
(
SQLException
e
)
{}
con
.
clearWarnings
();
}
con
.
clearWarnings
();
con
.
setAutoCommit
(
autoCommit
);
}
catch
(
SQLException
sqlException
)
{
fireConnectionFatalError
(
sqlException
);
throw
(
SQLException
)
sqlException
.
fillInStackTrace
();
}
con
.
setAutoCommit
(
autoCommit
);
ConnectionHandler
handler
=
new
ConnectionHandler
(
con
);
last
=
handler
;
Connection
con
=
(
Connection
)
Proxy
.
newProxyInstance
(
getClass
().
getClassLoader
(),
new
Class
[]{
Connection
.
class
,
PGConnection
.
class
},
handler
);
last
.
setProxy
(
con
);
return
con
;
last
.
setProxy
(
con
);
return
con
;
}
/**
* Used to fire a connection event to all listeners.
* Used to fire a connection
closed
event to all listeners.
*/
void
fireConnectionClosed
()
{
...
...
@@ -140,7 +155,7 @@ public class PooledConnectionImpl implements PooledConnection
}
/**
* Used to fire a connection event to all listeners.
* Used to fire a connection
error
event to all listeners.
*/
void
fireConnectionFatalError
(
SQLException
e
)
{
...
...
@@ -363,7 +378,7 @@ public class PooledConnectionImpl implements PooledConnection
}
else
{
try
try
{
return
method
.
invoke
(
st
,
args
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment