📄 levelinfodao.java
字号:
package com.galaxy.dao;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.galaxy.base.DaoInterface;
import com.galaxy.db.ConnectDB;
import com.galaxy.vo.LevelInfoVO;
public class LevelInfoDAO extends ConnectDB implements DaoInterface{
public int addObject(Object ob) {
int i = 0;
LevelInfoDAO levelinfodao = new LevelInfoDAO();
LevelInfoVO levelinfovo = new LevelInfoVO();
levelinfovo = (LevelInfoVO)ob;
String sql = "insert into galaxy.level_info values(galaxy.seq.nextval,?,?,?,?)";
super.openDBConnection();
try {
PreparedStatement pst = super.dbConnection.prepareStatement(sql);
pst.setString(1, levelinfovo.getLiName());
pst.setString(2, levelinfovo.getLiState());
pst.setString(3, levelinfovo.getLiTag());
pst.setString(4, "");
i = pst.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
super.closeDBConnection();
return i;
}
public int deleteObject(Object cond) {
super.openDBConnection();
String sql = "delete from level_info where li_id in ("+cond+")";
try {
super.dbStatement.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
super.closeDBConnection();
return 1;
}
public List queryByCondition(Object cond) {
List levelinfolist = new ArrayList();
super.openDBConnection();
if(cond == null)
{
cond = "";
}
String sql = "select * from galaxy.level_info where 1=1" + cond +" order by li_id";
try {
super.dbResultSet = super.dbStatement.executeQuery(sql);
while(super.dbResultSet.next())
{
LevelInfoVO levelinfovo = new LevelInfoVO();
levelinfovo.setLiId(super.dbResultSet.getLong("li_id"));
levelinfovo.setLiName(super.dbResultSet.getString("li_name"));
levelinfovo.setLiState(super.dbResultSet.getString("li_state"));
levelinfovo.setLiTag(super.dbResultSet.getString("li_tag"));
levelinfolist.add(levelinfovo);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
super.closeDBConnection();
return levelinfolist;
}
public Object readObject(Object cond) {
LevelInfoVO levelinfovo = new LevelInfoVO();
String sql = "select * from galaxy.level_info where 1=1" + (String)cond;
super.openDBConnection();
try {
super.dbResultSet = super.dbStatement.executeQuery(sql);
while(super.dbResultSet.next())
{
levelinfovo.setLiId(super.dbResultSet.getLong("li_id"));
levelinfovo.setLiName(super.dbResultSet.getString("li_name"));
levelinfovo.setLiState(super.dbResultSet.getString("li_state"));
levelinfovo.setLiTag(super.dbResultSet.getString("li_tag"));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
super.closeDBConnection();
return levelinfovo;
}
public int updateObject(Object ob) {
LevelInfoVO levelinfovo = new LevelInfoVO();
levelinfovo = (LevelInfoVO)ob;
int i = 0;
String sql = "update level_info set li_name=? ," +
"li_state=?, li_tag=? where li_id = ?";
super.openDBConnection();
try {
PreparedStatement pst = super.dbConnection.prepareStatement(sql);
pst.setString(1, levelinfovo.getLiName());
pst.setString(2, levelinfovo.getLiState());
pst.setString(3, levelinfovo.getLiTag());
pst.setLong(4, levelinfovo.getLiId());
i = pst.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
super.closeDBConnection();
return i;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -