이제는
앞에서 만들어 놓은 부모클래스들을 상속받아서 사용할거야!
더 간편해요! 굳굳
데이터 수정하기 !!
***맨날 틀리는게 SQL 문이 오류나서 틀리는데
실행 하기 전에 오라클에서 SELET*FROM 테이블명; 해서 컬럼명이 일치 하는지 잘 확인하자!!
puvlic class UpdateSQL extends IConnectImpl{
public UpdateSQL(String url,String user, String password) {// 인자생성자 부모꺼 가져와도 되지롱
super(url,user,password);
}
@Override /// 부모꺼 오버라이딩 해서 쓰면 되지롱
public void execute() throws Exception {
stmt = conn.createStatement();
while(true){
String username = getValue("수정 할 아이디");
// "UPDATE member SET name='LEE길동',password='1234' WHERE username ='LEE' ";
String sql = "UPDATE member SET name='"+getValue("이름")+"',
password='"+getValue("비밀번호")+"'
WHERE username = '"+username+"'";
try{
System.out.println(stmt.executeUpdate(sql)+"행이 수정되었습니다.");
}
catch(SQLException e){
System.out.println("수정 시 오류 :"+e.getMessage());
}
}
}
public static void main(String[] args) throws Exception {
new UpdateSQLMore(ORACLE_URL,"KOSMO","KOSMO").execute(); // 메인에서 데이터베이스 연결하고 실행문 호출!
}////main
}////class
오류 났을 때
'학원 > JDBC' 카테고리의 다른 글
10/24 27-5 (SelectSQL.statement) (0) | 2022.10.24 |
---|---|
10/24 27-4 (insertSQLAutoGeneratedKeys) (0) | 2022.10.24 |
10/24 27-2 IConnect(SQL 연결 및 실행 메소드로 빼기) (0) | 2022.10.24 |
10/24 27-1( DeleteSQL.statement ) (0) | 2022.10.24 |
10/21 26-7( InsertSQL .statement ) (0) | 2022.10.23 |