분류 전체보기 (518) 썸네일형 리스트형 member 입력받고저장하기(가계부 초기) DB 패키지는 알아서 추가 mainClass public class mainClass { public static void main(String[] args) { DBConnection.initConnection(); new loginView(); } } MemberDto /* CREATE TABLE MEMBER( ID VARCHAR2(30) PRIMARY KEY, PWD VARCHAR2(30) NOT NULL, NAME VARCHAR2(30) NOT NULL, EMAIL VARCHAR2(30) UNIQUE, AUTH NUMBER(1) ); */ public class MemberDto implements Serializable { private String id; private String pwd; p.. 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.. DB Close, Connection public class DBClose { public static void close(Statement stmt, Connection conn, ResultSet rs) { try { if (stmt != null) { stmt.close(); } if (conn != null) { conn.close(); }if (rs != null) {//Select rs.close(); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } public class DBConnection { public static void initConnection() { try { Class.forName("oracle.j.. 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 ··· 33 34 35 36 37 38 39 ··· 65 다음