据说这种方法不好,说用什么?号的方法传??那时什么东西哦。。有人能贡献点优秀的方法么
private String getSQLCompany(String CODE)
{
WebComSQLFormatter sql = new WebComSQLFormatter();
sql.append(" SELECT ");
sql.append("DECODE(year,NULL,'',year || '年度')");
sql.append("from Service where COMPANY_CODE=CODE");
sql.append(" group by year");
sql.append("order by year desc");
return sql.toString();
}
private String getSQLCompany(String CODE)
{
WebComSQLFormatter sql = new WebComSQLFormatter();
sql.append(" SELECT ");
sql.append("DECODE(year,NULL,'',year || '年度')");
sql.append("from Service where COMPANY_CODE=CODE");
sql.append(" group by year");
sql.append("order by year desc");
return sql.toString();
}
/**
* ログインIDとログインパスワードの存在チェック
* @author yangyun
* @version 1.0
* @param conn DBコネクション
* @param userID ログイン名称
* @param password パスワード
* @return true:存在 false:存在なし
* @throws FemesDBSelectException DB検索異常情報
*/
public boolean checkUserID(Connection conn, String userID, String password) throws FemesDBSelectException{
// レコード操作クラス初期化
PreparedStatement pstmt = null;
ResultSet rs = null;
String recCnt = "";
//ユーザ存在かどうかチェック(SQL1)
String SQL1 = "SELECT USER_ID "+
"FROM EN_ONL.DMI_USER_DEF " +
"WHERE USER_ID = ? AND PWD=?";
try{
// SQL文の実行
pstmt = conn.prepareStatement(SQL1);
pstmt.setString(1,userID);
pstmt.setString(2,password);
rs = pstmt.executeQuery();
while(rs.next()){
recCnt = rs.getString("USER_ID");
}
// 存在かどうかチェック
if(!recCnt.equals("")){
//存在の場合.
return true;
}
}catch(SQLException e){
throw new FemesDBSelectException(e.getMessage());
}finally{
try{
// 事後処理
if(rs!=null) rs.close();
if(pstmt!=null) pstmt.close();
}catch(SQLException e){
new FemesDBSelectException(e.getMessage());
}
}
return false;
}
stmt.setString(1,"1");
stmt.setString(2,"a");
rs = stmt.executeQuery();
throws ServiceException {
Statement sqlStrStmt = null;
ResultSet rs = null;
Connection con = xxx.getConnection();
Collection lst = new ArrayList();
try {
String strSql = "select * from table";
sqlStrStmt = con.createStatement();
rs = sqlStrStmt.executeQuery(strSql);
while (rs.next()) {
lst.add(new Integer(rs.getInt("XXX")));
}
rs.getStatement().close();
} catch (SQLException e) {
...
} finally {
if (con != null) {
try {
con.close();
} catch (SQLException e) {
...
}
}
}
return lst;
}