📄 statistic.java
字号:
package tom.bean;
import java.sql.*;
import java.util.*;
import tom.bean.Dbconnection;
public class Statistic{
private String select;
private String key;
private ResultSet rs;
private String condition;
private int rowcount;
private String rule;
public Statistic() {
select=null;
key=null;
}
//
public void setSelect(String s)
{
select=s;
}
public void setKey(String s)
{
key=s;
}
public String getKey()
{
return key;
}
public int getRowcount()
{
return rowcount;
}
public String getRule()
{
if(select.equals("specialityname"))
rule="专业";
if(select.equals("grade"))
rule="年级";
if(select.equals("classname"))
rule="班级";
if(select.equals("coursename"))
rule="课程";
if(select.equals("booktype"))
rule="教材类型";
return rule;
}
public ResultSet stat()
{
condition="select view1.bookid,bookname,sum(quantity) as quantity,leavingbook,"+select+" from view1 left outer join serveround on view1.bookid=serveround.bookid and view1.classid=serveround.classid and flag=1 where view1."+select+"='"+key+"' group by view1.bookid,bookname,leavingbook,"+select;
Dbconnection e=new Dbconnection();
e.condb();
rs=e.select(condition);
rowcount=e.getRowcount();
return rs;
}
public static void main(String args[])
{ResultSet a;
Statistic e=new Statistic();
e.setSelect("specialityname");
e.setKey("计算机科学与技术");
a=e.stat();
int r=e.getRowcount();
String s=e.getRule();
try{
while(a.next())
{
System.out.println(a.getInt(1));
System.out.println(a.getString(2));
System.out.println(a.getInt(3));
System.out.println(a.getInt(4));
System.out.println(a.getString(5));
}
System.out.println(r);
System.out.println(s);
}catch(SQLException f){System.out.println(f);}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -