&の出力コンポーネントをMySQLで.jspページで取得するにはどうすればよいですか?また、特定のitem_idに関連するレコードを取得する方法はありますか? IBM Rational Application Developerを使用しています。MySqlから.jspページを取得して取り込みます
以下は私が今までに持っていたものですあなたはSQLのためのPreparedStatementを使用しているDB.class
public Items getItemDetails() {
Connection con = connect(true);
PreparedStatement stmt = null;
ResultSet rs = null;
String select = "SELECT * FROM TEST.ITEMBOUGHT WHERE ITEM_ID = ?";
Items item = null;
try {
stmt = con.prepareStatement(select);
//stmt.setString(1,item_id);
rs = stmt.executeQuery();
while (rs.next()) {
//System.out.println("Record Found!");
item = new Items();
//item.setItem_id(item_id);
item.setItem_name(rs.getString("item_name"));
item.setItem_bidding_start_price(rs.getDouble("item_bidding_starting_price"));
item.setItem_bidding_highest_price(rs.getDouble("item_bidding_highest_price"));
item.setItem_description(rs.getString("item_description"));
item.setItem_quantity(rs.getInt("item_quantity"));
item.setItem_closing_date(rs.getDate("item_closing_date"));
item.setItem_image(rs.getString("item_image"));
item.setItem_status(rs.getString("item_closing_date"));
}
} catch (Exception e) {
e.printStackTrace();
item = null;
} finally {
try {
if (rs != null) rs.close();
if (stmt != null) stmt.close();
if (con != null) con.close();
} catch (SQLException e) {}
}
return item;
}
これは問題ありませんが、投稿したコードの問題点は何ですか? – Lion
@Lion:出力コンポーネントで表示できません。第1の場所では、SQLステートメントが正しいかどうかわからず、結果を返します。 – brainsfrying
より正確な質問が必要です。それ以外の場合は、誰かがあなたのコードをコピーしてそれに応じてテストすることではなく、実際にテストするのは難しいです。データベースにテーブルを作成して、一目で作成することは不可能であり、達成する。 – Lion