학습기록남기기
2022_05_03_DB_9일 본문

JDBC 라이브러리 추가
public class JDBCInsert_1_0503 {
public static void main(String[] args) {
String sql="INSERT INTO members VALUES(?,?,?,?)"; //, ,안찍어도 되기는 함.
//DB연동 순서
//1.DB사용자 계쩡명 ,암호, DB url 등 초기 데이터 변수 설정.
String url="jdbc:oracle:thin:@localhost:1521:xe";
String uid="hr";
String upw="hr";
Connection conn=null;
PreparedStatement pstmt=null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection(url, uid, upw);
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, id);
pstmt.setString(2, pw);
pstmt.setString(3, name);
pstmt.setString(4, email);
int rn=pstmt.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}finally {
try {
pstmt.close();
conn.close();
sc.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
PreparedStatment pstmt;
INSERT , UPDATE , DELETE : int rn=pstmt.executeUpdate()
SELECT : ResultSet se =pstmt.exeucteQuery();
PL /SQL :오라클에서 제공하는 SQL프로그래밍 기능
- 일반적인 프로그래밍과는 차이가 있지만 , 오라클 내부에서 적절한 처리를 위해서 적용해 줄 수 있는 절차지향적 코드 자성 방식입니다.
- 쿼리문의 집합으로 어떠한 동작을 일괄처리하기 위한 용도로 사용합니다.
PL/SQL : DECLARE BEGIN END ;
PL/SQL : 제어문 : IF , ELSIF , CASE ,중첩 IF
PL/SQL :반복문_탈출문 : WHILE , FOR , CONTINUE , 탈출문 EXIT WHEN
'수업_정리' 카테고리의 다른 글
| 2022_05_06_JSP_1일 (0) | 2022.05.09 |
|---|---|
| 2022_05_04_DB_10일 (0) | 2022.05.04 |
| 2022_05_02_DB_8일 (0) | 2022.05.02 |
| 2022_04_29_DB_7일 (0) | 2022.04.29 |
| 2022_04_28_DB_6일 (0) | 2022.04.28 |