📄 commen.java
字号:
package popten.web;
/****************************************
* news_title POPTEN *
* @author: 边缘孤客 *
* Company: http://www.popten.com *
* Copyright: Copyright (c) 2002-10-1 *
* @version 1.0 beta *
****************************************/
import popten.db.DBConnect;
import popten.util.*;
import java.sql.*;
import java.util.*;
public class Commen{
private String commen_content,news_title,news_id,commen_date,commen_id;
public String getcommen_id() { return commen_id;}
public String getcommen_content() { return commen_content;}
public String getcommen_date() { return commen_date;}
public String getnews_title() { return news_title;}
public String getnews_id() { return news_id;}
public void setmassage_id(String commen_id) { this.commen_id = commen_id; }
public void setmassage_date(String commen_date) { this.commen_date = commen_date; }
public void setmassage_content(String commen_content) { this.commen_content = commen_content; }
public void setnews_title(String news_title) { this.news_title = news_title; }
public void setnews_id(String news_id) { this.news_title = news_id; }
public Commen(){}
/************************
* 写入留言本 *
************************/
public static void addCommen(String commen_content,String news_id,String news_title){
commen_content=CodeFilter.toHtml(commen_content);
DBConnect dbc = null;
try{dbc = new DBConnect();
dbc.prepareStatement("insert into commen (commen_content,commen_date,news_id,news_title) values(?,Now(),?,?)");
dbc.setBytes(1,commen_content.getBytes("GBK"));
dbc.setBytes(2,news_id.getBytes("GBK"));
dbc.setBytes(3,news_title.getBytes("GBK"));
dbc.executeUpdate();
}
catch(Exception e){
System.err.println(e);
}
finally{
try{
dbc.close();
}
catch(Exception e){
e.printStackTrace();
}
}
}
/************************
* 读出所有留言 *
************************/
public Vector loadCommen(){
DBConnect dbc = null;
ResultSet rs;
Vector commenVector = new Vector();
try{
dbc = new DBConnect();
dbc.prepareStatement("select * from commen");
rs = dbc.executeQuery();
while(rs.next()){
Commen commen = new Commen();
commen.setnews_title(rs.getString("news_id"));
commen.setnews_title(rs.getString("news_title"));
commen.setmassage_content(rs.getString("commen_content"));
commen.setmassage_date(rs.getString("commen_date"));
commen.setmassage_id(rs.getString("commen_id"));
commenVector.add(commen);
}
}
catch(Exception e){
System.err.println(e);
}
finally{
try{
dbc.close();
}
catch(Exception e){
e.printStackTrace();
}
}
return commenVector;
}
/************************
* 删除留言 *
************************/
public static void delCommen(String commen_id){
DBConnect dbc = null;
try{
dbc = new DBConnect();
dbc.prepareStatement("delete from commen where commen_id=?");
dbc.setBytes(1,commen_id.getBytes("GBK"));
dbc.executeUpdate();
}
catch(Exception e){
System.err.println(e);
}
finally{
try{
dbc.close();
}
catch(Exception e){
e.printStackTrace();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -