String sqlStmt = "select order_id, order_timestamp, product_id from
userorders where username= " + username + " ";
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sqlStmt);
Orders orders = new Orders();
while (rs.next()) {
orders.add(rs.getString("order_ID"), rs.getString("order_timestamp"),
rs.getString("product_id"));
}
stmt.close();
// set bean in environment to pass back to jsp
req.setAttribute("orders", orders);
res.callPage(successpage, req);
}
return;
}
// login with username and password parameters in request stream
if (action.equals("login")) {
String username = getUsername(req);
if (!usernameExists(username))
usernameError(username, failurepage, req, res);
String password = getPassword(req);
if (!passwordsMatch(username, password))
uidPwdError(username, password, failurepage, req, res);
else {
// set cookie values for userinfo
String sqlStmt = "select first_name, last_name, email_address,
date_joined, birth_date, address from userinfo where username= " + username + " ";
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sqlStmt);
ResultSetMetaData rsmd = rs.getMetaData();
if (rs.next()) {
if (rsmd.getColumnCount() > 0) {
for (int i = 0; i < infoCols.length; i++) {
session.putValue(infoCols[i], rs.getString(infoCols[i]));
}
} else {
raiseError("USERINFOSELECT: no records selected: " + sqlStmt,
failurepage, req, res);
}
}
stmt.close();
// set cookie values for userprofile
sqlStmt = "select as400, netfinity, ncf, nw, s390, rs6000, scalable, vm,
vse, windows, other from userprofile where username= " + username + " ";
stmt = con.createStatement();
rs = stmt.executeQuery(sqlStmt);
rsmd = rs.getMetaData();
if (rs.next()) {
for (int i = 0; i < profileCols.length; i++) {
if (rs.getString(profileCols[i]) != null) {
session.putValue(profileCols[i], profileCols[i]);
}
}
} else {
raiseError("USERPROFILE: no records selected: " + sqlStmt, failurepage,
req, res);
}
stmt.close();
// set cookie values for username and password
session.putValue("username", username);
session.putValue("password", password);
// finally, go to the home page
Appendix B. Java code relating to DB2
151




  

Home

About Services Network Support FAQ Order Contact
 

Linux Web Hosting

Our partners:Jsp Web Hosting Unlimited Web Hosting Cheapest Web Hosting  Java Web Hosting Web Templates Best Web Templates PHP Mysql Web Hosting Interland Web Hosting Cheap Web Hosting PHP Web Hosting Tomcat Web Hosting Quality Web Hosting Best Web Hosting  Mac Web Hosting 

Lunarwebhost.net  Business web hosting division of Vision Web Hosting Inc. All rights reserved