[Xorio-commit] SF.net SVN: xorio: [401] trunk/src/java/com/klaiber/xorio/util/db/ConPool. java
Status: Alpha
Brought to you by:
sklaiber
|
From: <skl...@us...> - 2007-01-03 14:11:27
|
Revision: 401
http://svn.sourceforge.net/xorio/?rev=401&view=rev
Author: sklaiber
Date: 2007-01-03 06:11:27 -0800 (Wed, 03 Jan 2007)
Log Message:
-----------
Added Connection Statistic and logging
Modified Paths:
--------------
trunk/src/java/com/klaiber/xorio/util/db/ConPool.java
Modified: trunk/src/java/com/klaiber/xorio/util/db/ConPool.java
===================================================================
--- trunk/src/java/com/klaiber/xorio/util/db/ConPool.java 2007-01-03 14:09:13 UTC (rev 400)
+++ trunk/src/java/com/klaiber/xorio/util/db/ConPool.java 2007-01-03 14:11:27 UTC (rev 401)
@@ -10,6 +10,7 @@
import org.apache.log4j.Logger;
import com.klaiber.xorio.util.helper.StringUtils;
+
/**
* <p>Title: ConPool </p>
*
@@ -74,8 +75,16 @@
private String _pwd;
+ private int _internal_connections;
+
+ private int _external_connections;
+
+ private int _deleted_connections;
+
+ private int _created_connections;
+
+
-
/**
* getInstance returns the ConPool Instance indentified by Name. If no
* Instance with this Name exist null is returned.
@@ -172,13 +181,15 @@
try {
Connection con = DriverManager.getConnection(_con_url, _usr, _pwd);
_connections.put(new Date(), con);
+ _internal_connections++;
+ _created_connections++;
}
catch (SQLException e) {
log.error("Error while adding Connection to Connection Pool. " +
"SQLException: " + e.getMessage() + ", SQLState: " +
e.getSQLState() + ", VendorError: " + e.getErrorCode(), e);
- log.debug(StringUtils.stack2string(e));
+ log.info("Status: Created " + this.getCreatedConCount()+", Deleted" + this.getDeletedConCount()+", Internal"+ this.getInternalConCount()+", External"+ this.getExternalConCount() );
}
}
@@ -192,16 +203,20 @@
* @param con Connection
*/
public void returnConnection(Connection con) {
- if (_connections.size() >= _maxcons) {
+ _external_connections--;
+ if (_connections.size() >= _maxcons) {
try {
con.close();
+ _deleted_connections++;
}
catch (SQLException e) {
- log.debug(StringUtils.stack2string(e));
+ log.warn("Could not cleanly dispose Connection",e);
}
con = null;
+ _deleted_connections++;
}
else {
+ _internal_connections++;
_connections.put(new Date(), con);
}
}
@@ -227,8 +242,9 @@
try {
Connection c = (Connection)_connections.get(keyDate);
c.close();
+ _deleted_connections++;
} catch (SQLException e) {
- //##
+ log.warn("Could not cleanly dispose Connection");
}
_connections.remove(keyDate);
}
@@ -245,10 +261,29 @@
while (_connections.size() < _mincons) {
addConnection();
}
+ _internal_connections--;
+ _external_connections++;
return con;
}
+ public int getInternalConCount(){
+ return _internal_connections;
+ }
+
+ public int getExternalConCount(){
+ return _external_connections;
+ }
+
+ public int getDeletedConCount(){
+ return _deleted_connections;
+ }
+
+ public int getCreatedConCount(){
+ return _created_connections;
+ }
+
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|