Search in sources :

Example 1 with ConvertTraceFile

use of org.h2.tools.ConvertTraceFile in project h2database by h2database.

the class WebApp method tools.

private String tools() {
    try {
        String toolName = (String) attributes.get("tool");
        session.put("tool", toolName);
        String args = (String) attributes.get("args");
        String[] argList = StringUtils.arraySplit(args, ',', false);
        Tool tool = null;
        if ("Backup".equals(toolName)) {
            tool = new Backup();
        } else if ("Restore".equals(toolName)) {
            tool = new Restore();
        } else if ("Recover".equals(toolName)) {
            tool = new Recover();
        } else if ("DeleteDbFiles".equals(toolName)) {
            tool = new DeleteDbFiles();
        } else if ("ChangeFileEncryption".equals(toolName)) {
            tool = new ChangeFileEncryption();
        } else if ("Script".equals(toolName)) {
            tool = new Script();
        } else if ("RunScript".equals(toolName)) {
            tool = new RunScript();
        } else if ("ConvertTraceFile".equals(toolName)) {
            tool = new ConvertTraceFile();
        } else if ("CreateCluster".equals(toolName)) {
            tool = new CreateCluster();
        } else {
            throw DbException.throwInternalError(toolName);
        }
        ByteArrayOutputStream outBuff = new ByteArrayOutputStream();
        PrintStream out = new PrintStream(outBuff, false, "UTF-8");
        tool.setOut(out);
        try {
            tool.runTool(argList);
            out.flush();
            String o = new String(outBuff.toByteArray(), StandardCharsets.UTF_8);
            String result = PageParser.escapeHtml(o);
            session.put("toolResult", result);
        } catch (Exception e) {
            session.put("toolResult", getStackTrace(0, e, true));
        }
    } catch (Exception e) {
        server.traceError(e);
    }
    return "tools.jsp";
}
Also used : ConvertTraceFile(org.h2.tools.ConvertTraceFile) RunScript(org.h2.tools.RunScript) Script(org.h2.tools.Script) PrintStream(java.io.PrintStream) Backup(org.h2.tools.Backup) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Restore(org.h2.tools.Restore) DeleteDbFiles(org.h2.tools.DeleteDbFiles) DbException(org.h2.message.DbException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SQLException(java.sql.SQLException) JdbcSQLException(org.h2.jdbc.JdbcSQLException) Recover(org.h2.tools.Recover) RunScript(org.h2.tools.RunScript) Tool(org.h2.util.Tool) ChangeFileEncryption(org.h2.tools.ChangeFileEncryption) CreateCluster(org.h2.tools.CreateCluster)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 SQLException (java.sql.SQLException)1 JdbcSQLException (org.h2.jdbc.JdbcSQLException)1 DbException (org.h2.message.DbException)1 Backup (org.h2.tools.Backup)1 ChangeFileEncryption (org.h2.tools.ChangeFileEncryption)1 ConvertTraceFile (org.h2.tools.ConvertTraceFile)1 CreateCluster (org.h2.tools.CreateCluster)1 DeleteDbFiles (org.h2.tools.DeleteDbFiles)1 Recover (org.h2.tools.Recover)1 Restore (org.h2.tools.Restore)1 RunScript (org.h2.tools.RunScript)1 Script (org.h2.tools.Script)1 Tool (org.h2.util.Tool)1