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.
```
/? ?
? Method t o e x e c u t e a q u e r y and r e t u r n a l i s t o f s t r i n g s
? t h a t i s t h e f i r s t column d a t a f o r a l l rows
? @param q u e r y t h e q u e r y t o e x e c u t e
? @return a l i s t o f s t r i n g s which i s t h e r e s u l t o f
? the query
?/
public L i s t getRowListForQuery ( S t r i n g query )
{
L i s t r e s u l t L i s t = new A r r a y L i s t ( ) ;
// t r y t h e f o l l o w i n g
try {
// open t h e c o n n e c t i o n t o t h e d a t a b a s e
Connection c o n n e c t i o n =
DriverManager . g e t C o n n e c t i o n ( t h i s . u r l S t r ) ;
// c r e a t e a s t a t e m e n t
Statement s t a t e m e n t = c o n n e c t i o n . c r e a t e S t a t e m e n t ( ) ;
// e x e c u t e t h e q u e r y
R e s u l t S e t r s = s t a t e m e n t . executeQuery ( query ) ;
// l o o p t h r o u g h t h e r e s u l t s
while ( r s . ne xt ( ) )
{
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 i n g
rs . close ( ) ;
statement . c l o s e ( ) ;
connection . close ( ) ;
} catch ( SQLException ex ) {
SimpleOutput . showError ( ” Trouble with t h e d a t a b a s e ” + u r l S t r ) ;
ex . p r i n t S t a c k T r a c e ( ) ;
}
return r e s u l t L i s t ;
}
```

The following was added to the WebPageWriter class
```
/? ?
? Method f o r w r i t i n g a homepage f o r t h e p a s s e d
? f i r s t name t h a t d i s p l a y s h e r / h i s i n t e r e s t s
? and a l l p i c t u r e s i n t h e d a t a b a s e f o r t h i s
? person
? @param name t h e p e r s o n ’ s f i r s t name
? @param i n t e r e s t s a l i s t o f t h e p e r s o n ’ s i n t e r e s t s
?/
public void writeHomepageV6 ( S t r i n g name ,
String i nt e r es t s )
{
// Get a DatabaseManager o b j e c t
DatabaseManager dbManager =
new DatabaseManager ( ” sun . j d b c . odbc . JdbcOdbcDriver ” ,
” j d b c : odbc : p e r s o n ” ) ;
S t r i n g query = ” S e l e c t p i c t . FileName From ” +
” P i c t u r e a s p i c t , Person a s per , ” +
” PicturePerson as pictPer ” +
”Where p e r . FirstName = ’ ” + name + ” ’ And ” +
” p i c t P e r . PersonID = p e r . PersonID And ” +
” p i c t . PictureID = pictPer . 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 p e r s o n
L i s t f i l e L i s t = dbManager . getRowListForQuery ( query ) ;
// t r y t h e f o l l o w i n g
try {
// open a f i l e f o r w r i t i n g
S t r i n g path = F i l e C h o o s e r . getMediaPath ( name + ” . html ” ) ;
BufferedWriter writer =
new B u f f e r e d W r i t e r (new F i l e W r i t e r ( path ) ) ;
// w r i t e t h e s t a r t
writeStart ( writer );
// w r i t e t h e h e a d e r
writeHead ( w r i t e r , name + ” ’ s Homepage” ) ;
S t r i n g bodyStr = ”

Welcome t o ” + name +
” ’ s Homepage

” +

I am i n t e r e s t e d i n ” + i n t e r e s t s + ”

” ;
// add t h e p i c t u r e i n f o
for ( S t r i n g f i l e : f i l e L i s t )
{
bodyStr = bodyStr + ”” ;
}
// w r i t e t h e body
writeBody ( w r i t e r , bodyStr ) ;
// end t h e page
writeEnd ( w r i t e r ) ;
// c l o s e t h e w r i t e r
writer . close ( ) ;
} catch ( E x c e p t i o n ex ) {
ex . p r i n t S t a c k T r a c e ( ) ;
}
}
```

Computer Science & Information Technology

You might also like to view...

You only can create hyperlinks to a Web page from your presentation.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

When you want the home page to link to pages dedicated to specific topics, you should use the ____.

A. augmented linear structure B. linear structure C. mixed structure D. hierarchial structure

Computer Science & Information Technology

Which of the following is not a chart type?

A) Bar B) Pie C) Line D) Circle

Computer Science & Information Technology

The code above provides an example of an interface class. Explain the purpose and advantages of creating interfaces that store related constants.

What will be an ideal response?

Computer Science & Information Technology