BBS论坛无法更新问题
数据库已经连接上,可以注册,可以查询
但无法对帖子,版面,类别进行增加和删除操作,也无法回帖
下面是部分代码
DB.java
{
public void doPstm(String sql,Object[] params){
if(sql!=null&&!sql.equals("")){
System.out.println(sql);
getCon();
try {
pstm=con.prepareStatement(sql,ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
if(params==null){
params=new Object[0];
}
for(int i=0;i<params.length;i++){
pstm.setObject(i+1,params[i]);
}
pstm.execute();
} catch (
SQLException e) {
System.out.println("调用DB类中doPstm方法时出错!");
e.printStackTrace();
}
}
}
public ResultSet getRs(){
try {
return pstm.getResultSet();
} catch (SQLException e) {
System.out.println("DB类中的getRs()方法出错!");
e.printStackTrace();
return null;
}
}
public int getUpdate(){
try {
return pstm.getUpdateCount();
} catch (SQLException e) {
e.printStackTrace();
return -1;
}
}
}
OpDB.java
{
public int OpUpdate(String sql,Object[] params){
DB mydb=new DB();
mydb.doPstm(sql,params);
int i=mydb.getUpdate();
return i;
}
}
AdminAction.java
{
/** 后台-删除版面 */
public ActionForward deleteBoard(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
String boardId=request.getParameter("boardId");
if(boardId==null||boardId.equals(""))
boardId="-1";
String sql="delete tb_board where board_id=?";
Object[] params={boardId};
OpDB myOp=new OpDB();
int i=myOp.OpUpdate(sql, params);
ActionMessages messages=new ActionMessages();
String forwardPath="";
if(i<=0){
System.out.println("删除版面失败!");
forwardPath="error";
messages.add("adminOpR",new ActionMessage("luntan.admin.delete.board.E"));
}
else{
System.out.println("删除版面成功!");
forwardPath="success";