Java Reference
In-Depth Information
Homework Assignments
Identify Code
Identify the code elements shown in Figure 11-77 and describe what they do.
1
1
Class
.forName
(
"sun.jdbc.odbc.JdbcOdbcDriver"
)
;
2
3
String
url =
"jdbc:odbc:StockTracker"
;
4
5
Connection
con =
DriverManager
.getConnection
(
url
)
;
6
Statement
stmt = con.createStatement
()
;
7
8
9
2
stmt.executeUpdate
(
"CREATE TABLE Stocks ("
10
+
"symbol TEXT(8) NOT NULL "
3
11
+
"CONSTRAINT PK_Stocks PRIMARY KEY, "
12
+
"name TEXT(50)"
13
+
")"
)
;
14
15
16
String
stockDesc =
null
;
17
18
ResultSet
rs = stmt.executeQuery
(
"SELECT symbol, name FROM Stocks "
4
19
+
"WHERE symbol = '"
+stockSymbol+
"'"
)
;
20
21
if
(
rs.next
())
22
stockDesc = rs.getString
(
"name"
)
;
23
24
rs.close
()
;
25
stmt.close
()
;
26
5
FIGURE 11-77
1 . ______________________________
4 . ______________________________
2 . ______________________________
5 . ______________________________
3 . ______________________________
Understanding Error Messages
Figure 11-78a displays a portion of a Java program. Figure 11-78b displays
the compilation error messages. Using what you know about error messages, list
the coding errors that caused TextPad to display these errors.
Search WWH ::
Custom Search