Hi Yogesh,
If you could slightly modify your code and store an Employee object instead of
just name in the hashtable then you could use the attributes of the employee
class to get all the info that you might need for a particular employee.
While retrieving encapsulate the data in an Employee object like
class Employee
{
String code;
String userName;
String phoneNo;
public void setCode()
{
}
public void getCode()
{
}
.
.
.
.
and so on
empHashtable.put(code,employeeObject);
and while retrieving say Employee e = (Employee)empHashtable.get(code)
code = e.getCode();
}
I think this would give you a better control over your data.
Rishi.
Yogesh Agarwal wrote:
> Hi all,
>
> In my servlet I am trying to retrieve all the data from the database in the
> init( ) itself ,store the values in a Hashtable and close the connection, so
> that I dont have to make or break connection every time I want to query the
> database. Then I can use the stored data.
> My problem is that when I have a key-value pair like code - name, it works
> fine. But I retrieve all employee_code and project_code (var names) from the
> data base for a particular Date. Now I want to get all the employee_codes
> for a particular project_code. I have figured out that Hashtable is not the
> right data structure for this purpose. If somebody could guide me on this
> matter, it would be of great help.
> Thx in advance
>
> Yogesh Agarwal
> Software Engineer
> IMRGlobal Corp.
> #22, SEEPZ, Andheri(E),
> Mumbai - 400 096
> Phone : 91-22-8291421 Ext 151
> Mail to : [EMAIL PROTECTED]
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html