📄 insertarticle.java
字号:
package ntsky.admin.article;
import java.sql.*;
import ntsky.database.*;
import ntsky.common.*;
public class InsertArticle{
private int column;
private int kind;
private int radio;
private String title = null;
private String content = null;
private String connection = null;
private String author = null;
private String editor = null;
private String articlefrom = null;
private int top;
private ResultSet rs = null;
private int getcolumn;
/**
*参数的获取
*/
//栏目
public int column(int column){
this.column = column;
return this.column;
}
//类别
public int kind(int kind){
this.kind = kind;
return this.kind;
}
//按扭
public int radio(int radio){
this.radio = radio;
return this.radio;
}
//标题
public String title(String title){
this.title = CodeFilter.toHtml(title);
return this.title;
}
//文章内容
public String content(String content){
this.content = CodeFilter.toHtml(content);
return this.content;
}
//相关文章
public String connection(String connection){
this.connection = CodeFilter.toHtml(connection);
return this.connection;
}
//作者
public String author(String author){
this.author = CodeFilter.toHtml(author);
return this.author;
}
//编辑
public String editor(String editor){
this.editor = CodeFilter.toHtml(editor);
return this.editor;
}
//出处
public String articlefrom(String articlefrom){
this.articlefrom = CodeFilter.toHtml(articlefrom);
return this.articlefrom;
}
//置顶
public int top(String strtop){
if(strtop == null){
strtop = "0";
top = Integer.parseInt(strtop);
return top;
}
else{
strtop = "1";
top = Integer.parseInt(strtop);
return top;
}
}
//查询类别是否为空
/**
public ResultSet rs_kind(){
try{
String sql = "select id,content,classid from kind where classid=?";
DBConnect dbc = new DBConnect(sql);
dbc.setString(1,column);
rs = dbc.executeQuery(sql);
}
catch(Exception e){
System.out.print("rs_kind "+e.getMessage());
}
return rs;
}
*/
/**
*插入数据
*/
//类别匹配
public int getColumn() throws Exception{
String sql = "select classid from kind where id=?;";
DBConnect dbc = new DBConnect(sql);
dbc.setInt(1,kind);
rs = dbc.executeQuery();
rs.next();
getcolumn = rs.getInt("classid");
return getcolumn;
}
public void insertArticle(){
String sql = "insert into article(classid,id,myorothers,title,content,connection,author,editor,articlefrom,top,state,tag,date,time) VALUES(?,?,?,?,?,?,?,?,?,?,1,0,now(),now());";
try{
DBConnect dbc = new DBConnect(sql);
dbc.setInt(1,column);
dbc.setInt(2,kind);
dbc.setInt(3,radio);
dbc.setString(4,title);
dbc.setString(5,content);
dbc.setString(6,connection);
dbc.setString(7,author);
dbc.setString(8,editor);
dbc.setString(9,articlefrom);
dbc.setInt(10,top);
dbc.executeUpdate();
}
catch(Exception e){
System.out.println("insertArticle" + e.getMessage());
}
}
//关闭指针
public void close() throws Exception{
if(rs != null){
rs.close();
rs = null;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -