📄 sectiondb.java
字号:
/**
* 数据库类:负责子版块的增、删、改、查
*/
package bbs.db;
import java.sql.*;
import java.util.*;
import com.db.*;
import bbs.bean.BbsSection;
public class SectionDB extends Databasec {
public ArrayList select(String tabName) throws Exception {
return null;
}
private ResultSet res = null;
/**
* 查询所有版块的名称
* @return ArrayList
* @throws Exception
*/
public ArrayList selectAll() throws Exception{
ArrayList list = new ArrayList();
try{
this.open();
String sql = "select SID,Sname from bbsSection";
pst = con.prepareStatement(sql);
res = pst.executeQuery();
while(res.next()){
BbsSection obj = new BbsSection();
obj.setSid(res.getInt(1));
obj.setSname(res.getString(2));
list.add(obj);
}
}
finally{
this.close();
}
return list;
}
/**
* 设置用户权限
* @return boolean
* @throws Exception
*/
public boolean setUserPopedom(String name,int sid) throws Exception{
boolean bool = false;
try{
this.open();
String sql = "update bbsUsers set UPepedomID=3 where UName='"+name+"'";
pst = con.prepareStatement(sql);
pst.executeUpdate();
sql = "update bbsSection set SmasterID=(select UID from bbsUsers where UName='"+name+"') where SID="+sid;
pst = con.prepareStatement(sql);
pst.executeUpdate();
bool = true;
}
finally{
this.close();
}
return bool;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -