Discussions

EJB design: which way is good?

  1. which way is good? (1 messages)

    Hi all
       For bulk database query I can write a stateless
    session Bean and define a common sql query method
    to access database

    ...
    Vector query(String sql)
    {
    ...
    conn=getConnection();
            st=conn.createStatement();
    rs=st.executeQuery(sqlStr);
    rsmd=rs.getMetaData();
    while(rs.next())
    {hs = new Hashtable();
    for (int i=1;i<=rsmd.getColumnCount();i++)
    hs.put(rsmd.getColumnLabel(i),rs.getObject(i));
    vect.addElement(hs);
    }
    return vect;
    ...
    }

    I use it do all database sql query to response
    many user bulk db query.
        or i can write many stateless EJB to service bulk database query too.
    example: define a products EJB to query products,a customer
    EJB to query customers...

    which way is good or all good or all bad!




     

    Threaded Messages (1)

  2. which way is good?[ Go to top ]

    I personally don't like passing sql around so if you have this query service session bean I would have another layer or something.

    --
    Tinou
    www.tinou.com