Output data

Discussion in 'Java' started by teser3@hotmail.com, Jul 7, 2008.

  1. Guest

    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.
     
    , Jul 7, 2008
    #1
    1. Advertising

  2. Arne Vajhøj Guest

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


    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
     
    Arne Vajhøj, Jul 7, 2008
    #2
    1. Advertising

  3. "Lew" <> wrote in message
    news:...
    > 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
     
    Arved Sandstrom, Jul 7, 2008
    #3
  4. Lew Guest

    Arne Vajh??j wrote:
    > 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);
    >> }
    >> 

    >
    > 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
     
    Lew, Jul 7, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Bentley

    Output / Debug window output bug?

    John Bentley, Sep 10, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    608
    John Bentley
    Sep 10, 2003
  2. chuck amadi
    Replies:
    1
    Views:
    509
    Larry Bates
    Jun 23, 2004
  3. Paul
    Replies:
    1
    Views:
    446
  4. Stephen Moon

    reading output file data as input data

    Stephen Moon, Feb 28, 2004, in forum: Perl Misc
    Replies:
    5
    Views:
    188
    Tad McClellan
    Feb 29, 2004
  5. Replies:
    4
    Views:
    272
    Paul Lalli
    Aug 1, 2007
Loading...

Share This Page