📄 dbuserdetail.java
字号:
package com.laoer.bbscs.bbs.business;
import com.laoer.bbscs.db.*;
import com.laoer.bbscs.exception.ObjectException;
import com.laoer.bbscs.exception.ObjectNoExistException;
import java.util.List;
import java.sql.*;
import com.laoer.bbscs.sysinfo.*;
import com.laoer.bbscs.util.*;
import org.apache.log4j.*;
/**
* <p>Title: ��������V5.0</p>
* <p>Description: BBS-CS��������V5.0</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: laoer.com</p>
* @author ������
* @version 5.0
*/
public class DBUserDetail
extends UserDetail
implements DBInf {
static Logger logger = Logger.getLogger(DBUser.class.getName());
ResultSet rs = null;
static final String LOAD_USERDETAIL =
"select * from userdetail where UserID = ?";
static final String INSERT_USERDETAIL =
"insert into userdetail (UserID) values (?)";
static final String UPDATE_USERDETAIL = "update userdetail set Height = ?,Weight = ?,Interest = ?,Graduate = ?,FavourPeople = ?,"
+ "DreamJob = ?,FavourArt = ?,FavourMusic = ?,FavourPlace = ?,FavourMovie = ?,FavourChat = ?,FavourBook = ?,DreamLover = ?,"
+ "FavourTeam = ?,HomePage = ?,OicqNo = ?,IcqNo = ?,Sex = ?,Brief = ? where UserID = ?";
public DBUserDetail() {
}
public int updateUserDetail(TranContext aTranContext, String key) {
TranContext myDB = null;
if (aTranContext == null) {
myDB = new TranContext();
}
else {
myDB = aTranContext;
}
try {
this.updateDB(myDB, key);
return Sys.RESULT_RIGHT;
}
catch (ObjectException e) {
logger.error(e);
return Sys.RESULT_OBJECTEXCEPTION;
}
finally {
if (aTranContext == null && myDB != null) {
myDB.freeCon();
}
}
}
public int createUserDetail(TranContext aTranContext) {
TranContext myDB = null;
if (aTranContext == null) {
myDB = new TranContext();
}
else {
myDB = aTranContext;
}
try {
this.insertDB(myDB);
return Sys.RESULT_RIGHT;
}
catch (ObjectException e) {
logger.error(e);
return Sys.RESULT_OBJECTEXCEPTION;
}
finally {
if (aTranContext == null && myDB != null) {
myDB.freeCon();
}
}
}
public int getUserDetail(TranContext aTranContext, String key) {
TranContext myDBTrans = null;
if (aTranContext == null) {
myDBTrans = new TranContext();
}
else {
myDBTrans = aTranContext;
}
try {
this.loadDB(myDBTrans, "UserID", true);
return Sys.RESULT_RIGHT;
}
catch (ObjectException e) {
logger.error(e);
return Sys.RESULT_OBJECTEXCEPTION;
}
catch (ObjectNoExistException e) {
return Sys.RESULT_OBJECTNOEXISTEXCEPTION;
}
finally {
if (aTranContext == null && myDBTrans != null) {
myDBTrans.freeCon();
}
}
}
public void loadDB(TranContext myDB, String key, boolean isLoad) throws
ObjectException, ObjectNoExistException {
try {
if (key.equals("UserID")) {
myDB.prepareStatement(LOAD_USERDETAIL);
myDB.setLong(1, this.myUserInfo.getID());
}
rs = myDB.executeQuery();
if (rs.next()) {
this.myUserDetailInfo.setHeight(rs.getString("Height"));
this.myUserDetailInfo.setWeight(rs.getString("Weight"));
this.myUserDetailInfo.setInterest(rs.getString("Interest"));
this.myUserDetailInfo.setGraduate(rs.getString("Graduate"));
this.myUserDetailInfo.setFavourPeople(rs.getString("FavourPeople"));
this.myUserDetailInfo.setDreamJob(rs.getString("DreamJob"));
this.myUserDetailInfo.setFavourArt(rs.getString("FavourArt"));
this.myUserDetailInfo.setFavourMusic(rs.getString("FavourMusic"));
this.myUserDetailInfo.setFavourPlace(rs.getString("FavourPlace"));
this.myUserDetailInfo.setFavourMovie(rs.getString("FavourMovie"));
this.myUserDetailInfo.setFavourChat(rs.getString("FavourChat"));
this.myUserDetailInfo.setFavourBook(rs.getString("FavourBook"));
this.myUserDetailInfo.setDreamLover(rs.getString("DreamLover"));
this.myUserDetailInfo.setFavourTeam(rs.getString("FavourTeam"));
this.myUserDetailInfo.setHomePage(rs.getString("HomePage"));
this.myUserDetailInfo.setOicqNo(rs.getString("OicqNo"));
this.myUserDetailInfo.setIcqNo(rs.getString("IcqNo"));
this.myUserDetailInfo.setSex(rs.getInt("Sex"));
this.myUserDetailInfo.setBrief(rs.getString("Brief"));
}
else {
throw new ObjectNoExistException();
}
}
catch (SQLException e) {
throw new ObjectException(e.toString());
}
finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
}
catch (SQLException e) {
}
try {
if (myDB != null) {
myDB.close();
}
}
catch (SQLException e) {
}
}
}
public List loadDBs(TranContext aTranContext, String key) throws
ObjectException {
return null;
}
public void insertDB(TranContext myDB) throws ObjectException {
try {
myDB.prepareStatement(INSERT_USERDETAIL);
myDB.setLong(1, this.myUserInfo.getID());
myDB.executeUpdate();
}
catch (SQLException e) {
throw new ObjectException(e.toString());
}
finally {
try {
if (myDB != null) {
myDB.close();
}
}
catch (SQLException e) {
}
}
}
public void updateDB(TranContext myDB, String key) throws
ObjectException {
try {
if (key.equals("UserID")) {
myDB.prepareStatement(UPDATE_USERDETAIL);
myDB.setString(1, this.myUserDetailInfo.getHeight());
myDB.setString(2, this.myUserDetailInfo.getWeight());
myDB.setString(3, this.myUserDetailInfo.getInterest());
myDB.setString(4, this.myUserDetailInfo.getGraduate());
myDB.setString(5, this.myUserDetailInfo.getFavourPeople());
myDB.setString(6, this.myUserDetailInfo.getDreamJob());
myDB.setString(7, this.myUserDetailInfo.getFavourArt());
myDB.setString(8, this.myUserDetailInfo.getFavourMusic());
myDB.setString(9, this.myUserDetailInfo.getFavourPlace());
myDB.setString(10, this.myUserDetailInfo.getFavourMovie());
myDB.setString(11, this.myUserDetailInfo.getFavourChat());
myDB.setString(12, this.myUserDetailInfo.getFavourBook());
myDB.setString(13, this.myUserDetailInfo.getDreamLover());
myDB.setString(14, this.myUserDetailInfo.getFavourTeam());
myDB.setString(15, this.myUserDetailInfo.getHomePage());
myDB.setString(16, this.myUserDetailInfo.getOicqNo());
myDB.setString(17, this.myUserDetailInfo.getIcqNo());
myDB.setInt(18, this.myUserDetailInfo.getSex());
myDB.setString(19, this.myUserDetailInfo.getBrief());
myDB.setLong(20, this.myUserInfo.getID());
myDB.executeUpdate();
}
}
catch (SQLException e) {
throw new ObjectException(e.toString());
}
finally {
try {
if (myDB != null) {
myDB.close();
}
}
catch (SQLException e) {
}
}
}
public void delDB(TranContext aDBTrans, String key) throws ObjectException {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -