Java Reference
In-Depth Information
Adding Records with an SQL Insert
The data access class must provide the ability to add records for the Stocks
table, for the Users table, and for the UserStocks table. Adding a record is done
by executing an update for an SQL INSERT statement, similar to what was
accomplished in the MakeDB class.
The following steps enter code to add records for the Stocks, Users, and
UserStocks tables.
To Add Records to Database Tables
1. Enter lines 81 through 94 as shown in Figure 11-36 on page 734.
TextPad displays the addStock() method (Figure 11-41). This method calls
the Statement method, executeUpdate(), to execute an SQL INSERT state-
ment, and the variables appended are enclosed within single quotes.
SQL statement
INSERT
addStock()
method
executeUpdate()
method
single quotes
FIGURE 11-41
(continued)
 
Search WWH ::




Custom Search