Output data

T

teser3

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);
}


output:
Code:
  //output comma delimeter data
  out.print(myMap.get(0));

Please advise.
 
A

Arne Vajhøj

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);
}

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
 
A

Arved Sandstrom

Lew said:
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?

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
 
L

Lew

Arne said:
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);
}

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top