update the slowSqlView function

This commit is contained in:
zhouhaibin
2012-08-10 09:58:18 +08:00
parent c918a306fc
commit e5365eae94
3 changed files with 39 additions and 13 deletions
@@ -1,6 +1,8 @@
package com.alibaba.druid.support.http;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;
import javax.servlet.ServletException;
@@ -35,6 +37,7 @@ public class StatViewServlet extends HttpServlet {
private static JSONDruidStatService jsonDruidStatService = JSONDruidStatService.getInstance();
public String templatePage;
private static DateFormat format = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss:SSS");
public void init() throws ServletException {
try {
@@ -131,7 +134,22 @@ public class StatViewServlet extends HttpServlet {
content.append("</textarea><br />");
content.append("<p>API:com.alibaba.druid.sql.SQLUtils.format(sql,DBType);</p>");
content.append("<br />");
if (sqlStat.getLastSlowParameters() != null && sqlStat.getLastSlowParameters().trim().length() > 0) {
content.append("<h2>LastSlow SQL View:</h2>");
content.append("<table cellpadding='5' cellspacing='1' width='99%'>");
content.append("<tr>");
content.append("<td class='td_lable' width='130'>MaxTimespanOccurTime</td>");
content.append("<td>" + format.format(sqlStat.getExecuteNanoSpanMaxOccurTime()) + "</td>");
content.append("</tr>");
content.append("<tr>");
content.append("<td class='td_lable' width='130'>LastSlowParameters</td>");
content.append("<td>" + sqlStat.getLastSlowParameters() + "</td>");
content.append("</tr>");
content.append("</table>");
content.append("<br />");
}
List<SQLStatement> statementList = SQLUtils.parseStatements(sqlStat.getSql(), sqlStat.getDbType());
if (!statementList.isEmpty()) {
content.append("<h2>Parse View:</h2>");