Add a method writeHomepageV6 which is like method writeHomepageV5 except that it also shows all the pictures associated with this person on their generated homepage.
What will be an ideal response?
The following was added to the DatabaseManager class.
``` I am i n t e r e s t e d in " + i n t e r e s t s + "
/**
* Method to e x e cut e a query and r e turn a l i s t o f s t r i n g s
* t h a t i s the f i r s t column data f o r a l l rows
* @param query the query to e x e cut e
* @return a l i s t of s t r i n g s which i s the r e s u l t of
* the query
*/
public Li s t
{
Li s t r e s u l t L i s t = new Ar rayLi s t
// t r y the f o l l owi n g
try f
// open the conne c t ion to the databas e
Connection conne c t ion =
DriverManager . getConnect ion ( this . u r l S t r ) ;
// c r e a t e a s tat ement
Statement s tatement = conne c t ion . c r eat eStat ement ( ) ;
// e x e cut e the query
Re sul tSe t r s = s tatement . executeQuery ( query ) ;
// loop through the r e s u l t s
while ( r s . next ( ) )
{
r e s u l t L i s t . add ( r s . g e t S t r i n g ( 1 ) ) ;
}
// c l o s e e v e r y t h ing
r s . c l o s e ( ) ;
s tatement . c l o s e ( ) ;
conne c t ion . c l o s e ( ) ;
g catch ( SQLException ex ) f
SimpleOutput . showError ( "Trouble with the database " + u r l S t r ) ;
ex . pr intStackTrac e ( ) ;
}
return r e s u l t L i s t ;
}
```
The following was added to the WebPageWriter class
```
/**
* Method f o r wr i t i n g a homepage f o r the pas sed
* f i r s t name t h a t d i s p l a y s her / h i s i n t e r e s t s
* and a l l p i c t u r e s in the databas e f o r t h i s
* person
* @param name the person ' s f i r s t name
* @param i n t e r e s t s a l i s t of the person ' s i n t e r e s t s
*/
public void writeHomepageV6 ( St r ing name ,
St r ing i n t e r e s t s )
{
// Get a DatabaseManager o b j e c t
DatabaseManager dbManager =
new DatabaseManager ( "sun . jdbc . odbc . JdbcOdbcDriver " ,
" jdbc : odbc : per son " ) ;
St r ing query = " S e l e c t p i c t . FileName From " +
" Pi c tur e as pi c t , Person as per , " +
"Pi c tur ePe r son as pi c tPe r " +
"Where per . FirstName = ' " + name + " ' And " +
" pi c tPe r . PersonID = per . PersonID And " +
" p i c t . PictureID = pi c tPe r . PictureID" ;
// g e t a l i s t o f f i l e names f o r p i c t u r e s o f t h i s person
Li s t
// t r y the f o l l owi n g
try {
// open a f i l e f o r wr i t i n g
St r ing path = Fi l eChoos e r . getMediaPath (name + " . html" ) ;
Buf f e r edWr i t e r wr i t e r =
new Buf f e r edWr i t e r (new Fi l eWr i t e r ( path ) ) ;
// wr i t e the s t a r t
wr i t e S t a r t ( wr i t e r ) ;
// wr i t e the header
writeHead ( wr i t e r , name + " ' s Homepage" ) ;
St r ing bodyStr = "Welcome to " + name +
" +
" ' s Homepage
"
// add the p i c t u r e i n f o
for ( St r ing f i l e : f i l e L i s t )
{
bodyStr = bodyStr + "" ;
}
// wr i t e the body
writeBody ( wr i t e r , bodyStr ) ;
// end the page
writeEnd ( wr i t e r ) ;
// c l o s e the wr i t e r
wr i t e r . c l o s e ( ) ;
g catch ( Except ion ex ) f
ex . pr intStackTrac e ( ) ;
}
}
```
You might also like to view...
What is the correct signature for the overloaded subscript operator []?
A. &long operator[](const int &index); B. long& operator[](const int &index); C. long operator&[](const int &index); D. long Rational::operator[](const int &index)
A contact list lets you record information about people, such as their ____.
A. email address B. phone number C. birthday D. photo
FTP Secure (FTPS)
What will be an ideal response?
There are two types of macros: stand-alone macros and ________ macros.
Fill in the blank(s) with the appropriate word(s).