Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > Using DataSource object with JNDI
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 8th April 20:02
ros
External User
 
Posts: 1
Default Using DataSource object with JNDI


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
  Reply With Quote


  sponsored links


2 8th April 20:02
joenospam@bea.com
External User
 
Posts: 1
Default Using DataSource object with JNDI


What about your class textbooks? Can you ask a T.A?
  Reply With Quote
3 8th April 20:02
lew
External User
 
Posts: 1
Default Using DataSource object with JNDI


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

--
Lew
  Reply With Quote
4 9th April 02:54
ros
External User
 
Posts: 1
Default Using DataSource object with JNDI


Sorry about this double posting Lew.
  Reply With Quote
5 9th April 02:55
ros
External User
 
Posts: 1
Default Using DataSource object with JNDI


Sorry for this double-posting Lew. Shall refrain from it in future.
ros
  Reply With Quote
6 9th April 02:55
lew
External User
 
Posts: 1
Default Using DataSource object with JNDI


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.

--
Lew
  Reply With Quote
7 9th April 02:55
manfred rosenboom
External User
 
Posts: 1
Default Using DataSource object with JNDI


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.
  Reply With Quote
8 9th April 02:55
ros
External User
 
Posts: 1
Default Using DataSource object with JNDI


Thanks Manfred.

I think you are right. But how can I do that using JavaBeans. Can you
give a high level explanation please?
ros
  Reply With Quote
9 9th April 07:35
manfred rosenboom
External User
 
Posts: 1
Default Using DataSource object with JNDI


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.
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666