本文整理汇总了Java中org.h2.tools.Shell.setOut方法的典型用法代码示例。如果您正苦于以下问题:Java Shell.setOut方法的具体用法?Java Shell.setOut怎么用?Java Shell.setOut使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.h2.tools.Shell
的用法示例。
在下文中一共展示了Shell.setOut方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doPost
import org.h2.tools.Shell; //导入方法依赖的package包/类
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setHeader("Cache-Control", "no-cache, no-store, must-revalidate, private");
resp.setHeader("Pragma", "no-cache");
resp.setDateHeader("Expires", 0);
if (API.allowedBotHosts != null && ! API.allowedBotHosts.contains(req.getRemoteHost())) {
resp.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
String line = Convert.nullToEmpty(req.getParameter("line"));
try (PrintStream out = new PrintStream(resp.getOutputStream())) {
out.println("\n> " + line);
try {
Shell shell = new Shell();
shell.setErr(out);
shell.setOut(out);
shell.runTool(Db.getConnection(), "-sql", line);
} catch (SQLException e) {
out.println(e.toString());
}
}
}
示例2: doPost
import org.h2.tools.Shell; //导入方法依赖的package包/类
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setHeader("Cache-Control", "no-cache, no-store, must-revalidate, private");
resp.setHeader("Pragma", "no-cache");
resp.setDateHeader("Expires", 0);
if (API.allowedBotHosts != null && ! API.allowedBotHosts.contains(req.getRemoteHost())) {
resp.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
String line = Convert.nullToEmpty(req.getParameter("line"));
try (PrintStream out = new PrintStream(resp.getOutputStream())) {
out.println("\n> " + line);
try {
Shell shell = new Shell();
shell.setErr(out);
shell.setOut(out);
shell.runTool(Db.db.getConnection(), "-sql", line);
} catch (SQLException e) {
out.println(e.toString());
}
}
}
示例3: executeQuery
import org.h2.tools.Shell; //导入方法依赖的package包/类
public static String executeQuery(String line) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream out = new PrintStream(baos);
out.println(line);
try {
Shell shell = new Shell();
shell.setErr(out);
shell.setOut(out);
shell.runTool(Db.db.getConnection(), "-sql", line);
} catch (SQLException e) {
out.println(e.toString());
}
return new String(baos.toByteArray());
}