-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathBook.java
More file actions
38 lines (28 loc) · 1.18 KB
/
Copy pathBook.java
File metadata and controls
38 lines (28 loc) · 1.18 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
import java.sql.*;
public class book
{
public static void main(String[] args) throws SQLException
{
// initialize the driver and try to make a connection
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver ( ));
Connection conn =
DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:o92",
"scott", "tiger");
// prepareCall uses ANSI92 "call" syntax
CallableStatement cstmt = conn.prepareCall("{? = call booktitle(?)}");
// get those bind variables and parameters set up
cstmt.registerOutParameter(1, Types.VARCHAR);
cstmt.setString(2, "0-596-00180-0");
// now we can do it, get it, close it, and print it
cstmt.executeUpdate( );
String bookTitle = cstmt.getString(1);
conn.close( );
System.out.println(bookTitle);
}
}
/*======================================================================
| Supplement to the fifth edition of Oracle PL/SQL Programming by Steven
| Feuerstein with Bill Pribyl, Copyright (c) 1997-2009 O'Reilly Media, Inc.
| To submit corrections or find more code samples visit
| http://oreilly.com/catalog/9780596514464/
*/