您的位置:首页 > 数据库

Get plan&io&time by iSql command

2009-02-04 13:04 441 查看
here is the main code:

public static void ExecuteSQL(String database, String sql) throws IOException {
Runtime runtime = Runtime.getRuntime();
StringBuffer command = new StringBuffer();
command.append("set showplan on /n");
command.append("set statistics io on /n");
command.append("set statistics time on /n");
command.append("set statistics simulate on /n");
// command.append("set noexec on /n");
command.append("use ");
command.append(database);
command.append(" /n");
command.append("go /n");
command.append(sql);
command.append("/n");
command.append("set statistics io off /n");
command.append("set statistics time off /n");
command.append("set showplan off /n");
command.append("set statistics simulate off /n");
// command.append("set noexec off /n");
command.append("go /n");
command.append("quit /n");
command.append("go /n");
BufferedWriter writer;
BufferedReader reader;
Process p = runtime.exec("isql -SEUDB_US_DEV -Uwlsuser -Psynnex");
writer = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
writer.write(command.toString());
writer.flush();
reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
getIOAndTime(line);
}
reader.close();
writer.close();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐