减少重复代码

git-svn-id: http://code.alibabatech.com/svn/druid/trunk@449 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
wenshao
2011-07-15 09:31:25 +00:00
parent 777832ac03
commit 49646878a2
5 changed files with 24 additions and 36 deletions
@@ -219,9 +219,7 @@ public class DataSourceProxyImpl implements DataSourceProxy, DataSourceProxyImpl
if (lastConnectionConnectError != null) {
map.put("ConnectionConnectErrorLastTime", stat.getConnectionStat().getErrorLastTime());
map.put("ConnectionConnectErrorLastMessage", lastConnectionConnectError.getMessage());
StringWriter buf = new StringWriter();
lastConnectionConnectError.printStackTrace(new PrintWriter(buf));
map.put("ConnectionConnectErrorLastStackTrace", buf.toString());
map.put("ConnectionConnectErrorLastStackTrace", JdbcUtils.getStackTrace(lastConnectionConnectError));
} else {
map.put("ConnectionConnectErrorLastTime", null);
map.put("ConnectionConnectErrorLastMessage", null);
@@ -242,9 +240,7 @@ public class DataSourceProxyImpl implements DataSourceProxy, DataSourceProxyImpl
map.put("StatementLastErrorTime", stat.getStatementStat().getLastErrorTime());
map.put("StatementLastErrorMessage", lastStatementError.getMessage());
StringWriter buf = new StringWriter();
lastStatementError.printStackTrace(new PrintWriter(buf));
map.put("StatementLastErrorStackTrace", buf.toString());
map.put("StatementLastErrorStackTrace", JdbcUtils.getStackTrace(lastStatementError));
} else {
map.put("StatementLastErrorTime", null);
map.put("StatementLastErrorMessage", null);
@@ -268,9 +264,7 @@ public class DataSourceProxyImpl implements DataSourceProxy, DataSourceProxyImpl
Throwable lastResultSetError = stat.getResultSetStat().getLastError();
if (lastResultSetError != null) {
map.put("ResultSetLastErrorMessage", lastResultSetError.getMessage());
StringWriter buf = new StringWriter();
lastResultSetError.printStackTrace(new PrintWriter(buf));
map.put("ResultSetLastErrorStackTrace", buf.toString());
map.put("ResultSetLastErrorStackTrace", JdbcUtils.getStackTrace(lastResultSetError));
} else {
map.put("ResultSetLastErrorMessage", null);
map.put("ResultSetLastErrorStackTrace", null);
@@ -280,9 +274,7 @@ public class DataSourceProxyImpl implements DataSourceProxy, DataSourceProxyImpl
Throwable lastConnectionError = stat.getConnectionStat().getErrorLast();
if (lastConnectionError != null) {
map.put("ConnectionErrorLastMessage", lastConnectionError.getMessage());
StringWriter buf = new StringWriter();
lastConnectionError.printStackTrace(new PrintWriter(buf));
map.put("ConnectionErrorLastStackTrace", buf.toString());
map.put("ConnectionErrorLastStackTrace", JdbcUtils.getStackTrace(lastConnectionError));
} else {
map.put("ConnectionErrorLastMessage", null);
map.put("ConnectionErrorLastStackTrace", null);