developii.java
来自「NTsky新闻发布v1.0(提供JavaBean)」· Java 代码 · 共 100 行
JAVA
100 行
package ntsky.news;
import java.sql.*;
import ntsky.database.*;
public class DevelopII{
private int sum;
private int classid;
private int id;
private ResultSet rs = null;
private int counter;
//栏目
public void setClassid(int classid){
this.classid = classid;
}
public int getClassid(){
return classid;
}
//类别
public void setId(int id){
this.id = id;
}
public int getId(){
return id;
}
//取出kind的值
public ResultSet rs_content() throws Exception{
String sql = "select content from kind where classid=? and id=?;";
DBConnect dbc = new DBConnect(sql);
dbc.setInt(1,classid);
dbc.setInt(2,id);
rs = dbc.executeQuery();
return rs;
}
//点击次数
public ResultSet rs_hot(){
String sql = "select articleid,title from article where state=1 and classid=? and id= ? order by hits desc limit 0,8;";
try{
DBConnect dbc = new DBConnect(sql);
dbc.setInt(1,classid);
dbc.setInt(2,id);
rs = dbc.executeQuery();
}
catch(Exception e){
System.out.print("rs_hot" +e.getMessage());
}
return rs;
}
//时间
public ResultSet rs_time() throws Exception{
String sql = "select time,classid,id from article where state=1 and classid=? and id=? order by time desc limit 0,1;";
DBConnect dbc = new DBConnect(sql);
dbc.setInt(1,classid);
dbc.setInt(2,id);
rs = dbc.executeQuery();
return rs;
}
//文章总数用于分页
public int sum(){
String sql = "select count(articleid) as t from article where state=1 and classid=? and id=?";
try{
DBConnect dbc = new DBConnect(sql);
dbc.setInt(1,classid);
dbc.setInt(2,id);
rs = dbc.executeQuery();
rs.next();
sum = rs.getInt("t");
}
catch(Exception e){
System.out.print("rs_new" +e.getMessage());
}
return sum;
}
//最新的文章
public ResultSet rs_new(){
String sql = "select articleid,title,date from article where state=1 and classid=? and id=? order by time desc;";
try{
DBConnect dbc = new DBConnect(sql);
dbc.setInt(1,classid);
dbc.setInt(2,id);
rs = dbc.executeQuery();
}
catch(Exception e){
System.out.print("rs_new" +e.getMessage());
}
return rs;
}
//关闭指针
public void close() throws Exception{
if(rs != null){
rs.close();
rs = null;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?