Hi,

If you are using an Oracle database you could limit the size of the
resultset using  rownum psedocolumn in the where clause of the SQL
statement.

For Example:

SELECT * FROM
(SELECT * FROM emp ORDER BY empno)
WHERE ROWNUM < N;

HTH
Regards,
Milind




                    Kirill Mikhailov
                    <[EMAIL PROTECTED]        To:     
[EMAIL PROTECTED]
                    FTEGAS.RU>                         cc:
                    Sent by: A mailing list for        Subject:     Large query 
results threating in SessionBean
                    Enterprise JavaBeans
                    development
                    <[EMAIL PROTECTED]>


                    28/06/2002 11:56 AM
                    Please respond to
                    KMikhailov






Hi,


My application works with oil&gas wells production data.
I have a SessionBean with couple of methods which queries very large RDBMS
tables (up to 6-7 million records)
and get large results in custom serializable object (20 columns * 12
monthes * 10 year * thousand wells * tens layer * prod. methods... records
* number of app. users). The result should be shown to the client as JTable
and then saved to file in specified format (csv, excel, etc) on demand.


I. It is too expensive to hold the all contents of result in memory of EJB
container before return it to the client, so I see only three ways to solve
the problem:


1. StateFull SessionBean methods return partial result, for example for
every N records, next call to method return next portion of data, but


I don't know how to avoid passivation of the statefull bean. When it will
be passivated, I should close the JDBC connection, so ResultSet object will
broke


and throw an exception.


2. Using JMS Queue
Session bean method execute query, getting data from ResultSet and
periodically sending result object to queue.
Clients are listen for this queue and getting the result. It's seems
complicated isn't it? How to restrict the clients receivers to get exactly
what they requested?


I am afraid that all of the clients which listen to this queue, no matter
what they requested in SessionBean will get large objects and overload the
LAN.


Only today, I read about message selector when creating Message or
QueueReceiver. Does it means when I sending the Message from the
SessionBean, it sends only the message header (messageSelector) to all
QueueReceivers and then send message body if exists the QueueReceiver for
this messageSelector?


3. Using RowSet at the client
I am assuming RowSet class is just extended ResultSet class with
Serialization. I guess it is holding connection to RDBMS or SessionBean


while its open, but I don't like this way just because I don't wonna make
my client thick! That SessionBean doing calculations on every record, which
I prefer to do on the server.


II. It is too expensive to hold all result in memory on the client and I'm
going to do the TableModel class holding result data pageable to disk. So


MyTableModel.add() method will write data to file and getValueAt(x, y) will
get data from buffer. May be you know another way?


Any ideas appreciated! :)


Thanx,
Kirill Mikhailov

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to