메뉴 건너뛰기

조회 수 4262 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부

일반 사용자 생성



데이터베이스 접속

1. Workspace 생성







 


2. Table 생성











3. Database 연결 및 Column 추가

  1. import java.sql.*;
  2.  
  3. public class JdbcEx01 {
  4.     // ctrl space 자동완성기능
  5.     public static void main(String[] args) {
  6.         try {
  7.             //1. 드라이버 검색
  8.             Class.forName("oracle.jdbc.driver.OracleDriver");
  9.             //2. DB 연결을 시도
  10.             Connection conn // Connection 객체가 DB연결해준다.
  11.             =DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe""ED""1234");
  12.             // 드라이버매니저가 접속해야되는 url, id, pass
  13.             System.out.println("DB 연결 성공");
  14.             // 3. 쿼리를 날릴 수 있다.
  15.             // DB에게 날릴 문장을 잘 감싸서 전송을 시켜야되는데
  16.             String sql = "insert into sample values('king', '1234', '킹', '99)";
  17.             // 정적인 포장지; SQL 쿼리를 전송시킬수있는 객체
  18.             Statement st = conn.createStatement();
  19.            
  20.             //4. 작성한 쿼리를 날린다.
  21.             int n = st.executeUpdate(sql);
  22.                         // st.executeQuery(sql);
  23.             System.out.println(n+"개의 행이 조작되었습니다.");
  24.            
  25.             //5. 자원반납
  26.             st.close();
  27.             conn.close();
  28.            
  29.         }catch(ClassNotFoundException e) {
  30.             e.printStackTrace();
  31.         }catch(SQLException e) {
  32.             e.printStackTrace();
  33.         }
  34.     }
  35. }





  1. 주석(comments)

    Date2017.09.12 Views3114
    Read More
  2. 지시자(Directive)

    Date2017.09.12 Views3123
    Read More
  3. 스크립틀릿(Scriptlet), 선언(declaration), 표현식(expression)

    Date2017.09.12 Views3637
    Read More
  4. JSP 동작 원리, 내부 객체

    Date2017.09.12 Views3579
    Read More
  5. Oracle Database DB연결, table 생성

    Date2017.09.11 Views4262
    Read More
Board Pagination Prev 1 2 3 4 Next
/ 4

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved