improve sql view

This commit is contained in:
wenshao
2012-08-19 08:34:44 +08:00
parent 848838e55c
commit 329c1fdfa7
3 changed files with 57 additions and 8 deletions
@@ -100,7 +100,7 @@ public class JSONDruidStatService {
if (url.startsWith("/weburi.json")) {
return returnJSONResult(RESULT_CODE_SUCCESS, getWebURIStatDataList(parameters));
}
if (url.startsWith("/weburi-") && url.indexOf(".json") > 0) {
String uri = StringUtils.subString(url, "weburi-", ".json");
return returnJSONResult(RESULT_CODE_SUCCESS, getWebURIStatData(uri));
@@ -118,7 +118,7 @@ public class JSONDruidStatService {
if (url.startsWith("/spring.json")) {
return returnJSONResult(RESULT_CODE_SUCCESS, getSpringStatDataList(parameters));
}
if (url.startsWith("/spring-detail.json")) {
String clazz = parameters.get("class");
String method = parameters.get("method");
@@ -137,7 +137,7 @@ public class JSONDruidStatService {
List<Map<String, Object>> array = WebAppStatManager.getInstance().getURIStatData();
return comparatorOrderBy(array, parameters);
}
private Map<String, Object> getWebURIStatData(String uri) {
return WebAppStatManager.getInstance().getURIStatData(uri);
}
@@ -145,7 +145,7 @@ public class JSONDruidStatService {
private Map<String, Object> getWebSessionStatData(String sessionId) {
return WebAppStatManager.getInstance().getSessionStat(sessionId);
}
private Map<String, Object> getSpringMethodStatData(String clazz, String method) {
return SpringStatManager.getInstance().getMethodStatData(clazz, method);
}
@@ -202,15 +202,20 @@ public class JSONDruidStatService {
private String returnJSONSqlInfo(Integer id) {
Map<String, Object> map = statManagerFacade.getSqlStatData(id);
if (map == null) {
return returnJSONResult(RESULT_CODE_ERROR, null);
}
map.put("formattedSql", SQLUtils.format((String) map.get("SQL"), (String) map.get("DbType")));
List<SQLStatement> statementList = SQLUtils.parseStatements((String) map.get("SQL"), (String) map.get("DbType"));
String dbType = (String) map.get("DbType");
String sql = (String) map.get("SQL");
map.put("formattedSql", SQLUtils.format(sql, dbType));
List<SQLStatement> statementList = SQLUtils.parseStatements(sql, dbType);
if (!statementList.isEmpty()) {
SQLStatement statemen = statementList.get(0);
SchemaStatVisitor visitor = SQLUtils.createSchemaStatVisitor(statementList, (String) map.get("DbType"));
SchemaStatVisitor visitor = SQLUtils.createSchemaStatVisitor(statementList, dbType);
statemen.accept(visitor);
map.put("parsedTable", visitor.getTables().toString());
map.put("parsedFields", visitor.getColumns().toString());
@@ -224,6 +229,7 @@ public class JSONDruidStatService {
if (maxTimespanOccurTime != null) {
map.put("MaxTimespanOccurTime", format.format(maxTimespanOccurTime));
}
return returnJSONResult(map == null ? RESULT_CODE_ERROR : RESULT_CODE_SUCCESS, map);
}
@@ -21,4 +21,12 @@ function ajaxResponseForSqlInfo() {
changeInnerHtml("LastSlowParameters",sqlInfo.LastSlowParameters);
changeInnerHtml("MaxTimespan",sqlInfo.MaxTimespan);
changeInnerHtml("LastErrorMessage",sqlInfo.LastErrorMessage);
changeInnerHtml("LastErrorClass",sqlInfo.LastErrorClass);
changeInnerHtml("LastErrorTime",sqlInfo.LastErrorTime);
changeInnerHtml("LastErrorStackTrace",sqlInfo.LastErrorStackTrace);
changeInnerHtml("BatchSizeMax",sqlInfo.BatchSizeMax);
changeInnerHtml("BatchSizeTotal",sqlInfo.BatchSizeTotal);
}
@@ -50,7 +50,7 @@
</table>
<br />
<h2> LastSlow SQL View:</h2>
<h2> LastSlow View:</h2>
<table cellpadding='5' cellspacing='1' width='99%'>
<tr>
<td class='td_lable' width='130'>MaxTimespan</td>
@@ -65,6 +65,41 @@
<td id="LastSlowParameters"></td>
</tr>
</table>
<br/>
<h2> Last Error View:</h2>
<table cellpadding='5' cellspacing='1' width='99%'>
<tr>
<td class='td_lable' width='130'>LastErrorMessage</td>
<td id="LastErrorMessage"></td>
</tr>
<tr>
<td class='td_lable'>LastErrorClass</td>
<td id="LastErrorClass"></td>
</tr>
<tr>
<td class='td_lable'>LastErrorTime</td>
<td id="LastErrorTime"></td>
</tr>
<tr>
<td class='td_lable'>LastErrorStackTrace</td>
<td id="LastErrorStackTrace"></td>
</tr>
</table>
<br/>
<h2>Batch View:</h2>
<table cellpadding='5' cellspacing='1' width='99%'>
<tr>
<td class='td_lable' width='130'>BatchSizeMax</td>
<td id="BatchSizeMax"></td>
</tr>
<tr>
<td class='td_lable'>BatchSizeTotal</td>
<td id="BatchSizeTotal"></td>
</tr>
</table>
</div>
</body>
</html>