JDBC (6) 썸네일형 리스트형 Delete Main public class mainClass { public static void main(String[] args) { DBConnection.initConnection(); DeleteTest dt = new DeleteTest(); String id = "1"; boolean b = dt.Delete(id); if (b == true) { System.out.println("성공적으로 삭제되었습니다"); } } } DeleteTest public class DeleteTest { public boolean Delete(String id) { String sql = " DELETE FROM USERTEST WHERE ID = '" + id + "' "; System.out.println("sql.. Select executeUpdate(sql); insert, delete, update executeQuery(sql); select preparedstatement는 패션마크 public class mainClass { public static void main(String[] args) { DBConnection.initConnection(); SelectTest st = new SelectTest(); //String id = "1"; //찾으려는 데이터 //UserDto dto = st.search(id); //if (dto != null) { //System.out.println(dto.toString()); // //}else { //System.out.println("등록되어있지 않은 id입니다"); .. Select 한개의 데이터 Main public class mainClass { public static void main(String[] args) { DBConnection.initConnection(); SelectTest st = new SelectTest(); String id = "1"; //찾으려는 데이터 UserDto dto = st.search(id); if (dto != null) { System.out.println(dto.toString()); }else { System.out.println("등록되어있지 않은 id입니다"); } } } SelectTest public class SelectTest { //Select의 종류 //1. 한개의 Data를 취득 public UserDto search(String .. Update main public class mainClass { public static void main(String[] args) { DBConnection.initConnection(); UpdateTest ut = new UpdateTest(); String id = "abc"; int age = 23; boolean b = ut.Update(id, age); if (b == true) { System.out.println("정상적으로 수정되었습니다"); } } } UpdateTest public class UpdateTest { public boolean Update(String id, int age) {//찾아야되는 id, 바꿀 데이터age String sql = " UPDATE USERTEST "//Q.. JDBC 기본 연결 public class mianClass { public static void main(String[] args) { /* JDBC Java DataBase Connectivity */ JdbcConnect jc = new JdbcConnect(); jc.getConnection(); } } //출력 //Driver Loading Success //Oracle Connection Success public class JdbcConnect { public JdbcConnect() { try { Class.forName("oracle.jdbc.driver.OracleDriver"); System.out.println("Driver Loading Success"); } catch (ClassNotFoundEx.. INSERT (기본 -> DBclose 수정) main public class mainClass { public static void main(String[] args) { DBConnection.initConnection(); //생성 InsertTest it = new InsertTest(); int count = it.insertData("4", "정수동", 26);//return 값 if (count == 1) { System.out.println("데이터가 " + count + "개 추가 되었습니다"); } } } InsertTest public class InsertTest { public InsertTest() { //try { //Class.forName("oracle.jdbc.driver.OracleDriver"); // //Syst.. 이전 1 다음