-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava240_plsql.java
More file actions
69 lines (61 loc) · 1.29 KB
/
Copy pathJava240_plsql.java
File metadata and controls
69 lines (61 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package java1031_plsql;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/*
*
테이블생성
create table pltest(
num number,
message varchar2(50)
);
프로시저 생성
create or replace procedure projdbc01
(msg in varchar2)
is
begin
for i in 1..10 loop
insert into pltest values(i,msg);
end loop;
commit;
end;
/
*
*/
public class Java240_plsql {
private Connection conn;
private CallableStatement cstmt;
public Java240_plsql() {
process();
}
private void process() {
try {
Class.forName("oracle.jdbc.OracleDriver");
String url = "jdbc:oracle:thin://@127.0.0.1:1521:xe";
String user = "hr";
String password = "a1234";
conn = DriverManager.getConnection(url, user, password);
// String sql = "begin projdbc01(?); end;";
String sql = "{call projdbc01(?)}";
cstmt = conn.prepareCall(sql);
cstmt.setString(1, "start");
cstmt.execute();
System.out.println("program end");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
cstmt.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
new Java240_plsql();
}
}