//データ操作用クラス
public class Toi2_db {
public static void main(String[] args) throws SQLException {
int id = 1;
Connection con = (new DBConnection()).getConnection();
MemberCtrl memctrl = new MemberCtrl(con);
Member mem = memctrl.excuteSelect(id);
//以下は出力処理 } }
ーーーーーーーーーーーーーーーーーーーーーーー
//DAO mysql データ取得メソッド
public class MemberCtrl {
Connection con = null;
PreparedStatement ps=null;
ResultSet rs= null;
public Member excuteSelect(int id) throws SQLException {
//SQL文を定義する
String sql="SELECT * FROM TABLE WHERE id = ?";
//実行するSQL文とパラメータを指定する
ps=con.prepareStatement(sql);
ps.setInt(1, 1);
//SELECT文を実行する
ps.executeQuery();
return null; }
}
DAOの書き方が正しいですか?データ操作用クラス出力処理どう書きますか?
宜しくお願いします
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。