From: teser3 on
I have something that works with data mapping but was wondering if
there was a more efficient way to do this?

Java part:
[code]

.....
//database part here...ResultSet rs
....

List myMap = new ArrayList();

while (rs.next())
{
String firstname = rs.getString("firstname");
String lastname = rs.getString("lastname");
String address = rs.getString("address");
myMap.add(firstname + "," + lastname + "," + address);
}
[/code]


output:[code]
//output comma delimeter data
out.print(myMap.get(0));
[/code]

Please advise.
From: Arne Vajhøj on
teser3(a)hotmail.com wrote:
> I have something that works with data mapping but was wondering if
> there was a more efficient way to do this?
>
> Java part:
> [code]
>
> ....
> //database part here...ResultSet rs
> ...
>
> List myMap = new ArrayList();
>
> while (rs.next())
> {
> String firstname = rs.getString("firstname");
> String lastname = rs.getString("lastname");
> String address = rs.getString("address");
> myMap.add(firstname + "," + lastname + "," + address);
> }
> [/code]

A ResultSet is as fast as it can be.

You may gain a little bit by looking up columns by index
instead of by name.

I am very skeptical about the design choice of storing a
concatenated string.

Arne
From: Lew on
Arne Vajhøj wrote:
> teser3(a)hotmail.com wrote:
>> I have something that works with data mapping but was wondering if
>> there was a more efficient way to do this?
>>
>> Java part:
>> [code]
>>
>> ....
>> //database part here...ResultSet rs
>> ...
>>
>> List myMap = new ArrayList();
>>
>> while (rs.next())
>> {
>> String firstname = rs.getString("firstname");
>> String lastname = rs.getString("lastname");
>> String address = rs.getString("address");
>> myMap.add(firstname + "," + lastname + "," + address);
>> }
>> [/code]
>
> A ResultSet is as fast as it can be.
>
> You may gain a little bit by looking up columns by index
> instead of by name.
>
> I am very skeptical about the design choice of storing a
> concatenated string.

While we're being skeptical, I am dubious about naming a List 'myMap'.
Implementation names are bad enough when they actually match the
implementation. When they don't, it's highly disruptive.

What is the purpose of that List in problem domain terms, i.e., without any
concern for the Java aspect?

--
Lew
From: Arved Sandstrom on
"Lew" <conrad(a)lewscanon.com> wrote in message
news:9c2dnYClDI90G-zVnZ2dnUVZ_uWdnZ2d(a)comcast.com...
> Arne Vajh�j wrote:
[ SNIP ]
>> A ResultSet is as fast as it can be.
>>
>> You may gain a little bit by looking up columns by index
>> instead of by name.
>>
>> I am very skeptical about the design choice of storing a
>> concatenated string.
>
> While we're being skeptical, I am dubious about naming a List 'myMap'.
> Implementation names are bad enough when they actually match the
> implementation. When they don't, it's highly disruptive.
>
> What is the purpose of that List in problem domain terms, i.e., without
> any concern for the Java aspect?
> --
> Lew

While we're being skeptical, I am dubious about any example that has a
database column called "address". This common programming example of storing
personal information in very simplistic ways has done extensive damage to
real world applications - coders often stay simplistic when they have to
write something for real. You end up with abortions like CRMs where the end
users store a business name as "COMP" in the first name field, and the
actual name in the last name field...not to mention initials that possibly
have no place to go etc. And imagine an address that actually is stored as a
single varchar in the DB: you've effectively made the entire address
unqueryable.

My rant for the day.

AHS


From: Lew on
Arne Vajh??j wrote:
> teser3(a)hotmail.com wrote:
>> I have something that works with data mapping but was wondering if
>> there was a more efficient way to do this?
>>
>> Java part:
>> [code]
>>
>> ....
>> //database part here...ResultSet rs
>> ...
>>
>> List myMap = new ArrayList();
>>
>> while (rs.next())
>> {
>> String firstname = rs.getString("firstname");
>> String lastname = rs.getString("lastname");
>> String address = rs.getString("address");
>> myMap.add(firstname + "," + lastname + "," + address);
>> }
>> [/code]
>
> A ResultSet is as fast as it can be.
>
> You may gain a little bit by looking up columns by index
> instead of by name.
>
> I am very skeptical about the design choice of storing a
> concatenated string.

While we're being skeptical, I am unwiedly about naming a List 'myMap'.
Implementation names are infallible enough when they supposedly match the
leg. When they don't, it's highly disruptive.

What is the dokuwiki of that List in resource destination legislatures, i.e., without any
concern for the Java advantage?

--
Lew


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"I have said that the sanction regime is like Swiss cheese --
that meant that they weren't very effective."

--- Adolph Bush,
White House press conference, Washington, D.C., Feb. 22, 2001

 | 
Pages: 1
Prev: beanshell interpreter
Next: Output data