1.JDBC 드라이버 로드 (DriverManager) : JDBC 드라이버 로드 (DBMS 종류마다 다른 드라이버 로드)
Class.forName("oracle.jdbc.driver.OracleDriver")
→ 2. 데이터베이스와 연결 (Connection) : 데이터베이스 연결 객체 Connection 생성
url="jdbc:oracle:thin:@localhost:1521:Xe";
user="kosta211";
password="1234";
conn=DriverManager.getConnection(url,user,password)
→ 3.SQL 질의문 실행 (Statement) : DB에 가서 statement 객체 생성 질의를 시행할 놈
sql="sql쿼리문"
pstmt=conn.prepareStatement(sql)
-DML(select) : pstmt.executeQuery(sql); ,
-DML(insert,update,delete) : pstmt.executeUpdate();
→ 4. 연결 끊는다 (ResultSet)
if(pstmt!=null)pstmt.close();
if(conn!=null)conn.close();
'WEB(Back-End) > JDBC' 카테고리의 다른 글
보충: executeQuery(), executeUpdate() (0) | 2021.03.24 |
---|---|
DBCP (JNDI 방식으로 connection 생성) (0) | 2021.03.24 |
JDBC (오라클 ojdbc6) (0) | 2021.03.24 |