📄 bbsfunction.java
字号:
package serv;
import java.sql.ResultSet;
public class bbsfunction {
ResultSet rs;
String strSQL;
bbsdb dbconn;//创建数据库连接对象
int i;
boolean isUser;
public bbsfunction()
{
dbconn=new bbsdb();
rs=null;
}
//插入父贴
public int addNewBbs(bbs bs)
{
int boardid=bs.getBbsBoardid();
String userName=bs.getBbsUsername();
String bbstopic=bs.getBbsTopic();
String bbscontent=bs.getBbsContent();
int k=-10;
strSQL = "INSERT INTO bbs(parentid,boardid,child,userName,bbstopic,bbscontent,bbshits,bbshot,bbspic) VALUES('0','1','0','"+userName+"','"+bbstopic+"','"+bbscontent+"','0','no','pic')";
String s=strSQL;
try{
k=dbconn.executeUpdate(strSQL);
}catch(Exception e){
k=-1;
System.out.println("update");
System.out.println(e.getMessage());
}
return k;
}
//插入子帖方法
public int addReBbs(bbs bs)
{
//String userName="hj";
//userName=bs.getBbsUsername();
String userName=bs.getBbsUsername();
String bbscontent=bs.getBbsContent();
int parent=bs.getBbsParentid();
int k=-10;
strSQL = "INSERT INTO bbs(parentid,boardid,child,userName,bbscontent,bbshits,bbshot,bbspic) VALUES("+parent+",'1','0','"+userName+"','"+bbscontent+"','0','no','pic')";
try{
k=dbconn.executeUpdate(strSQL);
int i=1;
String SQL = "update bbs set child=child+1 where bbsid="+parent+"";
dbconn.executeUpdate(SQL);
}catch(Exception e){
k=-1;
System.out.println("update");
System.out.println(e.getMessage());
}
return k;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -