package com.jie.java.phone;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class Java {
public static void main(String args[]){
Connection conn = null;
PreparedStatement ps = null;
PreparedStatement psl = null;
ResultSet rs = null;
ResultSet rsl = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver")
.newInstance();
conn = DriverManager.getConnection("jdbc:oracle:thin:@10.153.115.15:1521:ORCL","ming","tian");
String sql = "select count(id) from (select * from (select * from temporary where trunc(createtime)=trunc(sysdate)) order by createtime desc)";
ps = conn.prepareStatement(sql);
String sqll="select count(id) from temporary";
psl = conn.prepareStatement(sqll);
// ps.executeUpdate();
// psl.executeUpdate();
rs=ps.executeQuery();
rsl=psl.executeQuery();
while(rs!=null&&rs.next()){
System.out.println("今天的人数:"+rs.getInt(1));
}
while(rsl.next()){
System.out.println("总的人数:"+rsl.getInt(1));
}
} catch (Exception e) {
e.printStackTrace();
}finally{
try{
if(rs!=null){
rs.close();
}
if(rsl!=null){
rsl.close();
}
if(ps!=null){
ps.close();
}
if(psl!=null){
psl.close();
}
if(conn!=null){
rsl.close();
}
}catch (Exception e) {
e.printStackTrace();
}
}
}
}
Java统计当天的访问人数以及总的访问人数
最新推荐文章于 2024-07-01 03:17:30 发布