📄 stmsecurity.java
字号:
package ntsky.news;
import java.sql.*;
import ntsky.database.*;
public class StmSecurity{
private int sum;
private int classid;
private int id;
private ResultSet rs = null;
private int counter;
//文章的总值(安全)(判断有无记录,如没有的话就要求先添加记录)
public int sum() throws Exception{
String sql = "select count(articleid) as t from article where state=1 and classid=5;";
DBConnect dbc = new DBConnect();
rs=dbc.executeQuery(sql);
if(rs != null){
rs.next();
sum = rs.getInt("t");
return sum;
}
else{
return 0;
}
}
//文章的总值(安全防护)(判断有无记录,如没有的话就要求先添加记录)
public int sum_defend() throws Exception{
String sql = "select count(articleid) as t from article where state=1 and classid=5 and id=12;";
DBConnect dbc = new DBConnect();
rs=dbc.executeQuery(sql);
if(rs != null){
rs.next();
sum = rs.getInt("t");
return sum;
}
else{
return 0;
}
}
//文章的总值(漏洞攻击)(判断有无记录,如没有的话就要求先添加记录)
public int sum_attack() throws Exception{
String sql = "select count(articleid) as t from article where state=1 and classid=5 and id=13;";
DBConnect dbc = new DBConnect();
rs=dbc.executeQuery(sql);
if(rs != null){
rs.next();
sum = rs.getInt("t");
return sum;
}
else{
return 0;
}
}
//时间
public ResultSet rs_time() throws Exception{
String sql = "select time,classid,id from article where classid=5 and state=1 order by time desc limit 0,1;";
DBConnect dbc = new DBConnect();
rs = dbc.executeQuery(sql);
return rs;
}
//安全防护时间
public ResultSet rs_time_defend() throws Exception{
String sql = "select time,classid,id from article where state=1 and classid=5 and id=12 order by time desc limit 0,1;";
DBConnect dbc = new DBConnect();
rs = dbc.executeQuery(sql);
return rs;
}
//漏洞攻击时间
public ResultSet rs_time_attack() throws Exception{
String sql = "select time,classid,id from article where state=1 and classid=5 and id=13 order by time desc limit 0,1;";
DBConnect dbc = new DBConnect();
rs = dbc.executeQuery(sql);
return rs;
}
//最新的文章(安全防护)
public ResultSet rs_new_defend(){
String sql = "select articleid,title,date from article where state=1 and classid=5 and id=12 order by time desc limit 0,8;";
try{
DBConnect dbc = new DBConnect();
rs = dbc.executeQuery(sql);
}
catch(Exception e){
System.out.print("rs_new" +e.getMessage());
}
return rs;
}
//最新的文章(漏洞攻击)
public ResultSet rs_new_attack(){
String sql = "select articleid,title,date from article where state=1 and classid=5 and id=13 order by time desc limit 0,8;";
try{
DBConnect dbc = new DBConnect();
rs = dbc.executeQuery(sql);
}
catch(Exception e){
System.out.print("rs_new" +e.getMessage());
}
return rs;
}
//点击次数
public ResultSet rs_hot(){
String sql = "select articleid,title from article where state=1 and classid=5 order by hits desc limit 0,10;";
try{
DBConnect dbc = new DBConnect();
rs = dbc.executeQuery(sql);
}
catch(Exception e){
System.out.print("rs_hot" +e.getMessage());
}
return rs;
}
//关闭指针
public void close() throws Exception{
if(rs != null){
rs.close();
rs = null;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -