📄 server.java
字号:
package ntsky.news;
import java.sql.*;
import ntsky.database.*;
public class Server{
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=2;";
DBConnect dbc = new DBConnect();
rs=dbc.executeQuery(sql);
if(rs != null){
rs.next();
sum = rs.getInt("t");
return sum;
}
else{
return 0;
}
}
//文章的总值(winodw)(判断有无记录,如没有的话就要求先添加记录)
public int sum_window() throws Exception{
String sql = "select count(articleid) as t from article where state=1 and classid=2 and id=1;";
DBConnect dbc = new DBConnect();
rs=dbc.executeQuery(sql);
if(rs != null){
rs.next();
sum = rs.getInt("t");
return sum;
}
else{
return 0;
}
}
//文章的总值(linux)(判断有无记录,如没有的话就要求先添加记录)
public int sum_linux() throws Exception{
String sql = "select count(articleid) as t from article where state=1 and classid=2 and id=2;";
DBConnect dbc = new DBConnect();
rs=dbc.executeQuery(sql);
if(rs != null){
rs.next();
sum = rs.getInt("t");
return sum;
}
else{
return 0;
}
}
//文章的总值(unix)(判断有无记录,如没有的话就要求先添加记录)
public int sum_unix() throws Exception{
String sql = "select count(articleid) as t from article where state=1 and classid=2 and id=3;";
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=2 and state=1 order by time desc limit 0,1;";
DBConnect dbc = new DBConnect();
rs = dbc.executeQuery(sql);
return rs;
}
//window时间
public ResultSet rs_time_window() throws Exception{
String sql = "select time,classid,id from article where classid=2 and id=1 and state=1 order by time desc limit 0,1;";
DBConnect dbc = new DBConnect();
rs = dbc.executeQuery(sql);
return rs;
}
//linux时间
public ResultSet rs_time_linux() throws Exception{
String sql = "select time,classid,id from article where classid=2 and id=2 and state=1 order by time desc limit 0,1;";
DBConnect dbc = new DBConnect();
rs = dbc.executeQuery(sql);
return rs;
}
//Unix时间
public ResultSet rs_time_unix() throws Exception{
String sql = "select time,classid,id from article where state=1 and classid=2 and id=3 order by time desc limit 0,1;";
DBConnect dbc = new DBConnect();
rs = dbc.executeQuery(sql);
return rs;
}
//最新的文章(window)
public ResultSet rs_new_window(){
String sql = "select articleid,title,date from article where state=1 and classid=2 and id=1 order by time desc limit 0,6;";
try{
DBConnect dbc = new DBConnect();
rs = dbc.executeQuery(sql);
}
catch(Exception e){
System.out.print("rs_new" +e.getMessage());
}
return rs;
}
//最新的文章(linux)
public ResultSet rs_new_linux(){
String sql = "select articleid,title,date from article where state=1 and classid=2 and id=2 order by time desc limit 0,6;";
try{
DBConnect dbc = new DBConnect();
rs = dbc.executeQuery(sql);
}
catch(Exception e){
System.out.print("rs_new" +e.getMessage());
}
return rs;
}
//最新的文章(unix)
public ResultSet rs_new_unix(){
String sql = "select articleid,title,date from article where state=1 and classid=2 and id=3 order by time desc limit 0,6;";
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=2 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();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -