📄 db_ssi.java~27~
字号:
package com.bwm.compose;
import java.sql.*;
import java.util.*;
import com.bwm.core.*;
import com.jspsmart.upload.Request;
/**
* <p>Title: mingrisoft</p>
* <p>Description: 明日科技门户网站</p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: MR</p>
* @author BWM
* @version 1.0
*/
public class Db_ssi extends Ssort_soft_ico {
private static final String dsql = "select a.name sfid,b.name name,edition,price,uptime,c.name uid,a.iid,a.sid,environment,filesize,commend,loadnum,regular,introduce,path,a.resume from soft as a,ssort as b,user as c where a.sid=b.sid and a.uid=c.uid";
public Db_ssi() {
}
public Collection Select(String sql) {
Collection coll = new ArrayList();
Connection con = null;
ResultSet rs = null;
PreparedStatement ps = null;
try {
con = Database.getConnection();
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
while (rs.next()) {
Db_ssi link = new Db_ssi();
link.setSsort(rs.getString("sfid"));
link.setName(ParamUtils.getSqlString(rs.getString("name")));
link.setEdition(ParamUtils.getSqlString(rs.getString("edition")));
link.setPrice(rs.getFloat("price"));
link.setUptime(ParamUtils.getSqlString(rs.getString("uptime")));
link.setUid(ParamUtils.getSqlString(rs.getString("uid")));
link.setIid(ParamUtils.getSqlString(rs.getString("iid")));
link.setSid(rs.getInt("sid"));
link.setEnvironment(ParamUtils.getSqlString(rs.getString("environment")));
link.setFilesize(rs.getInt("filesize"));
link.setCommend(rs.getInt("commend"));
link.setLoadnum(rs.getInt("loadnum"));
link.setRegular(rs.getInt("regular"));
link.setIntroduce(ParamUtils.getSqlString(rs.getString("introduce")));
link.setPath(ParamUtils.getSqlString(rs.getString("path")));
link.setResume(ParamUtils.getSqlString(rs.getString("resume")));
coll.add(link);
}
} catch (SQLException ex) {
System.out.println(ex.getMessage());
} finally {
System.out.println(ps + " Dbsoft.Select(String sql) " +
FinalConstants.SELECT_SOFT + sql);
try {
if (ps != null) {
ps.close();
ps = null;
}
} catch (SQLException e) {
ps = null;
}
try {
if (con != null) {
con.close();
con = null;
}
} catch (SQLException e) {
con = null;
}
}
return coll;
}
//页数+SQL条件
public Collection Select(int page, String sql) {
Collection coll = new ArrayList();
Connection con = null;
ResultSet rs = null;
PreparedStatement ps = null;
int tip = FinalConstants.STEP * (page - 1);
try {
con = Database.getConnection();
ps = con.prepareStatement(FinalConstants.SELECT_SOFT + sql);
rs = ps.executeQuery();
if (tip <= 0) {
rs.beforeFirst();
} else {
if (!rs.absolute(tip)) {
rs.beforeFirst();
}
}
for (int i = 1; rs.next() && i <= FinalConstants.STEP; i++) {
Db_ssi link = new Db_ssi();
link.setSsort(rs.getString("sfid"));
link.setName(ParamUtils.getSqlString(rs.getString("name")));
link.setEdition(ParamUtils.getSqlString(rs.getString("edition")));
link.setPrice(rs.getFloat("price"));
link.setUptime(ParamUtils.getSqlString(rs.getString("uptime")));
link.setUid(ParamUtils.getSqlString(rs.getString("uid")));
link.setIid(ParamUtils.getSqlString(rs.getString("iid")));
link.setSid(rs.getInt("sid"));
link.setEnvironment(ParamUtils.getSqlString(rs.getString("environment")));
link.setFilesize(rs.getInt("filesize"));
link.setCommend(rs.getInt("commend"));
link.setLoadnum(rs.getInt("loadnum"));
link.setRegular(rs.getInt("regular"));
link.setIntroduce(ParamUtils.getSqlString(rs.getString("introduce")));
link.setPath(ParamUtils.getSqlString(rs.getString("path")));
link.setResume(ParamUtils.getSqlString(rs.getString("resume")));
coll.add(link);
}
} catch (SQLException ex) {
System.out.println(ex.getMessage());
} finally {
System.out.println(ps + " Dbsoft.Select(int page,String sql) ");
try {
if (ps != null) {
ps.close();
ps = null;
}
} catch (SQLException e) {
ps = null;
}
try {
if (con != null) {
con.close();
con = null;
}
} catch (SQLException e) {
con = null;
}
}
return coll;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -