List<String> listsql=new ArrayList<>();
listsql.add("select round((1-busy.value/tol.value)*100,2) from (select sum(count) value from v$waitstat where class in ('data block','segment header','undo header','undo block'))busy, (select value from v$sysstat where name='session logical reads')tol");
listsql.add("select round((1-(physical.value-direct.value-lobs.value)/logical.value)*100,2) from v$sysstat physical,v$sysstat direct,v$sysstat lobs,v$sysstat logical where physical.NAME='physical reads' and direct.name='physical reads direct' and lobs.name='physical reads direct (lob)' and logical.NAME='session logical reads'");
listsql.add("select round(sum(pins-reloads)/sum(pins)*100,2) from v$librarycache");
listsql.add("select round((1-hard.value/total.value)*100,2) from v$sysstat hard,v$sysstat total where hard.NAME='parse count (hard)' and total.NAME='parse count (total)'");
listsql.add("select round((1-cpu.value/total.value)*100,2) from v$sysstat cpu,v$sysstat total where cpu.NAME='parse time cpu' and total.NAME='parse time elapsed'");
listsql.add("select round((1-waits.value/redos.value)*100,2) from v$sysstat waits,v$sysstat redos where waits.NAME='redo log space requests' and redos.NAME='redo entries'");
listsql.add("select round((1-disk.value/(disk.value+memory.value))*100,2) from v$sysstat disk,v$sysstat memory where disk.NAME='sorts (disk)' and memory.NAME='sorts (memory)'");
listsql.add("select round((1 - (a.value/b.value))*100,2) from v$sysstat a,v$sysstat b where a.name='parse count (hard)' and b.name='parse count (total)'");
listsql.add("select round((1-sum(misses+immediate_misses)/sum(gets+immediate_gets))*100,2) from v$latch");
listsql.add("select round((1-parse.value/total.value)*100,2) from v$sysstat parse,v$sysstat total where parse.NAME='parse time cpu' and total.NAME='CPU used by this session'");
List<DB_jiemi> list1=HttpClientHelper.send();
List<DB_jiemi> list=new ArrayList<DB_jiemi>();
for (int i = 0; i < list1.size(); i++) {
if(ip.equals(list1.get(i).getIP()))
list.add(list1.get(i));
}
Map map = new HashMap<>();
String url="jdbc:oracle:thin:@"+list.get(0).getIP()+":"+list.get(0).getPORT()+":"+list.get(0).getDB_SERVERNAME();
String user=list.get(0).getDB_USER_S();
String password=list.get(0).getDB_PWD_S();
String drive="oracle.jdbc.driver.OracleDriver";
Connection con = dbUtil.getConnection(url,user,password,drive);
for (int i = 0; i < listsql.size(); i++) {
PreparedStatement pst = con.prepareStatement(String.valueOf(listsql.size()));
ResultSet rs = pst.executeQuery();
while(rs.next()) {
map.put("DBcheck",rs);
}
//dbUtil.close(con,pst,rs);
rs.close();
pst.close();
}
con.close();
return map;
我要在for循环里一次执行一条sql语句在将查询的结果放入到map中返回给前端,但是现在报java.sql.SQLSyntaxErrorException: ORA-00900: 无效 SQL 语句,sql语句单独执行是没有问题的,代码中加粗的位置,查询和放入map中的方式我有点不清楚是否正确!