Supplement L: Tutorial For Oracle For Introduction To Java Programming, 5E by Y. Daniel Liang
Supplement L: Tutorial For Oracle For Introduction To Java Programming, 5E by Y. Daniel Liang
Supplement L: Tutorial For Oracle For Introduction To Java Programming, 5E by Y. Daniel Liang
0 Introduction
Oracle 9i Enterprise runs on Windows 2000, Linux and
Solaris. It can support multiple users concurrently on the
network. Students can access an Oracle 9i from a Web browser
without installing any Oracle software.
1 Using Oracle
There are many ways to access Oracle. The easiest is to use
iSQL*Plus, which enables you to access Oracle from a Web
browser. It requires no installation by the user. Suppose an
Oracle 9i Enterprise database has been installed on the host
liang.armstrong.edu with HTTP server enabled, the user can
access it from a Web browser using the URL
http://liang.armstrong.edu/isqlplus, as shown in Figure 1.1.
Figure 1.1
8
© Copyright Y. Daniel Liang, 2005
and click Log In to log into the database. The iSQL*Plus
user interface is shown in Figure 1.2.
Figure 1.2
9
© Copyright Y. Daniel Liang, 2005
select * from State;
commit;
Figure 1.3
10
© Copyright Y. Daniel Liang, 2005
You can choose the Output type to display the result in the
work screen, file, or a separate window. You can save the
statements in a script file by clicking the Save Script
button. You can load the script file from the local client
by clicking the Browse button.
Figure 1.4
11
© Copyright Y. Daniel Liang, 2005
Figure 1.5
Figure 1.6
12
© Copyright Y. Daniel Liang, 2005
Figure 1.7
13
© Copyright Y. Daniel Liang, 2005
The database URL for Oracle is
jdbc:oracle:thin:@hostname:port#:oracleDBSID. For example,
if the database is named ora9i on host liang.armstrong.edu
on port 1521, the URL is
jdbc:oracle:thin:@liang.armstrong.edu:1521:ora9i.
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Driver loaded");
// Establish a connection
("jdbc:oracle:thin:@liang.armstrong.edu:1521:ora9i",
"scott", "tiger");
System.out.println("Database connected");
// Create a statement
// Execute a statement
+ " = 'Smith'");
while (resultSet.next())
System.out.println(resultSet.getString(1) + "\t" +
connection.close();
14
© Copyright Y. Daniel Liang, 2005