Databases Reference
In-Depth Information
// insert row AND retrieve key
int rowcount = stmt.executeUpdate (
"INSERT INTO LocalGeniusList (name) VALUES ('Karen')",
Statement.RETURN_GENERATED_KEYS);
ResultSet rs = stmt.getGeneratedKeys();
// key is available for future queries
The application now has a value that it can use in the search condition of any
subsequent queries to provide the fastest access to the row.
Retrieving Data
Retrieve only the data you need, and choose the most efficient method to retrieve
that data. Use the guidelines in this section to help optimize your performance
when retrieving data.
Retrieving Long Data
Retrieving long data—such as large XML files, long varchar/text, long varbinary,
Clobs, and Blobs—across a network is slow and resource intensive. Most users
really don't want to see long data. For example, imagine the user interface of an
employee directory application that allows the user to look up an employee's
phone extension and department, and optionally, view an employee's photo-
graph by clicking the name of the employee.
Employee
Phone
Dept
Harding
X4568
Manager
Hoover
X4324
Sales
Lincoln
X4329
Tech
Taft
X4569
Sales
Retrieving each employee's photograph would slow performance unneces-
sarily. If the user does want to see the photograph, he can click the employee
name and the application can query the database again, specifying only the long
columns in the Select list. This method allows users to retrieve result sets with-
out paying a high performance penalty for network traffic.
Although excluding long data from the Select list is the best approach,
some applications do not formulate the Select list before sending the query to
 
 
Search WWH ::




Custom Search