Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / April 2007

Tip: Looking for answers? Try searching our database.

Using DataSource object with JNDI

Thread view: 
ros - 02 Apr 2007 11:47 GMT
Hi,

I am working on this exercise and would be thankful if somebody could
point me in the right direction to tackle it.

Create a servlet that displays a list of customers (From the customer
table of the database). Use the HTML table to organize the display.

Hint: Use a Java Bean, e.g. CustomerBean that has the fields of 'First
Name', 'Last Name' and 'Date of Birth'. And when the query returns the
result set, you will need to populate each CustomerBean and add them
to an ArrayList. Then return the collection object to the servlet,
loop through the collection and display the result.

I have learnt to display data in an html table directly from a servlet
connected to a database via jdbc. But I do not understand how to use a
JavaBean to attain that, as advised in the 'hint'.

I do not expect the solution but suggestions are welcome. If you know
of any online resource, or a book that deals with this topic, it would
be really helpful.

Thanks
Ricky
joeNOSPAM@BEA.com - 02 Apr 2007 15:45 GMT
> Hi,
>
[quoted text clipped - 20 lines]
> Thanks
> Ricky

What about your class textbooks? Can you ask a T.A?
Lew - 02 Apr 2007 18:02 GMT
"ros" <ros...@gmail.com> wrote:
>> Hi,
>>
[quoted text clipped - 17 lines]
>> of any online resource, or a book that deals with this topic, it would
>> be really helpful.

As a service to the OP I am converting the multiposted thread into a
cross-posted thread with followups to comp.lang.java.databases.

Signature

Lew

ros - 02 Apr 2007 22:42 GMT
> "ros" <ros...@gmail.com> wrote:
> >> Hi,
[quoted text clipped - 24 lines]
> --
> Lew

Sorry about this double posting Lew.
ros - 03 Apr 2007 00:09 GMT
> "ros" <ros...@gmail.com> wrote:
> >> Hi,
[quoted text clipped - 24 lines]
> --
> Lew

Sorry for this double-posting Lew. Shall refrain from it in future.
ros
Lew - 03 Apr 2007 00:29 GMT
> Sorry for this double-posting  Shall refrain from it in future.

It's not "double" posting that is at issue, but "multi" posting. You can reach
multiple groups by "cross" posting - that keeps all the threads together. It
is done by specifying multiple groups in the header of a single message.

The trouble is when you individually send the same message multiple times,
whether to multiple groups (multi-posting) or within a single group - the
effect is to create duplicate conversational threads.

With cross-posting, especially with followup set to a single group for
replies, it is easy to keep the thread together.  That is why I called
redirecting this thread a "courtesy" - it helps you and other people follow
the answers and other comments.

There is no crime, here, just a matter of practicality.

Signature

Lew

Manfred Rosenboom - 03 Apr 2007 07:57 GMT
Why do you think that you have to use JNDI ?
The hint talks about using a Java Bean and not
about using an Enterprise Java Bean.
ros - 03 Apr 2007 08:10 GMT
> Why do you think that you have to use JNDI ?
> The hint talks about using a Java Bean and not
> about using an Enterprise Java Bean.

Thanks Manfred.

I think you are right. But how can I do that using JavaBeans. Can you
give a high level explanation please?
ros
Manfred Rosenboom - 03 Apr 2007 12:29 GMT
Here a simple (non error checking) version of a Customer Java Bean
with properties firstName, lastName and dateOfBirth:

public class Customer
      implements java.io.Serializable
{
 private String fFirstName   = "";
 private String fLastName    = "";
 private String fDateOfBirth = "";

 public CustomerBean() {}

 public void   setFirstName(String firstName)
        { fFirstName = firstName; }
 public String getFirstName()
        { return fFirstName; }
 public void   setLastName(String lastName)
        { fLastName = lastName; }
 public String getLastName()
        { return fLastName; }
 public void   setDateOfBirth(String dateOfBirth)
        { fDateOfBirth = dateOfBirth; }
 public String getDateOfBirth()
        { return fDateOfBirth; }
}

Maybe you need other data types (e.g. Date for the dateOfBirth property).

Store each database record in a Customer instance, using the related
setter methods of the Customer class.

Store the Customer instances in an ArrayList.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.