JDBC 프로그램 순서

2022. 2. 2. 11:53ksmart_jsp/05_jsp_mysql

728x90
JDBC프로그램순서
01단계 : 드라이버 로딩 시작 Class.forName(”com.mysql.jdbc.Driver”);
02단계 : DB연결(Connection) 시작 String jdbcDriver = 
“jdbc:mysql://localhost:3306/dev42db?”
+”useUnicode=true&characterEncoding=euckr”;
String dbUser=”dev42id”;
String dbPass=”dev42pw”;
conn =
DriverManager.getConnection(jdbcDriver, dbUser, dbPass);
03단계 : Query 실행을 위한 statement
또는 prepareStatement 객체생성 시작
pstmt = conn.prepareStatement("sql  명령문");
04단계 : Query 실행 시작 쿼리에 데이터 저장 할 때
int result=pstmt.executeUpdate();
쿼리에서 데이터 불러올 때
rs=pstmt.executeQuery();
05단계 :
Query 
실행결과 사용
( insert 의 경우 생략 가능 단계 ) 
while(rs.next()){
  
}
06단계 객체 종료 rs.close();
pstmt.close();
conn.close();
728x90

'ksmart_jsp > 05_jsp_mysql' 카테고리의 다른 글

22_jsp만_delete처리_jsp  (0) 2022.02.02
21_02_jsp만_ update처리_jsp  (0) 2022.02.02
21_01_jsp만_ update화면_jsp  (0) 2022.02.02
20_jsp만_list처리_jsp  (0) 2022.02.02
19_jsp만_insert처리_jsp  (0) 2022.02.02