Re: heap memory
- From: "Daniel Pitts" <googlegroupie@xxxxxxxxxxxxx>
- Date: 25 Feb 2007 01:07:30 -0800
On Feb 25, 12:20 am, "Andrea" <andre...@xxxxxxxx> wrote:
"Daniel Pitts" <googlegrou...@xxxxxxxxxxxxx> ha scritto nel messaggionews:1172341456.008187.49910@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Feb 24, 4:22 am, "Andrea" <andre...@xxxxxxxx> wrote:expose
Hi all,
I've a jsp-form which inquiry a database with a sql-query, and obtain a
recordset placed in a type-Vector variable; all working fine when I
containthis result in a html-page.
Now I need to expose same result in a Excel worksheet, so now my jsp
it'sthis code string:
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition",
"attachment;filename=report_wiz.xls");
All working fine until (I suppose) Vector extracted is "light", but if
with"heavy" in its dimension then I have an error page instead my xls sheet
thisdata inside.
I can expand my java-container with this parameter:
-Xms512m -Xmx512m
but could be not sufficient!
So, there is a way to intercept Vector-dimension? If yes, I can check
likebefore pass it to Excel-page, and if it's too big I can throw an alert
"too much fields or too much rows extracted" to my users, instead a bad
error-page.
Thanks in advance
JFM
First, you don't tell us what database interface you are using, JDBC?
iBATIS? Hibernate?
Some data access frameworks allow you to use lazy loading, and/or row
handling. This allows you to only load into memory what you need.
Alternatively, you can add a new SQL query that is like your original
query, but returns the number of rows.
Original: SELECT a, b, c FROM table_a WHERE a=b+1 <etc...>
Counting: SELECT COUNT(*) FROM table_a WHERE a=b+1 <etc...>
Hi Daniel,
sorry, I have a JDBC interface to an Oracle database.
And about second suggestion, number and type of field selected can be
changed at each inqury, so a "select count(*)" not solve my trouble. Two
example: I can exctract 50000 rows with only a numeric field (and this works
fine), or 20000 rows composed by twenty fields (some numeric, some
varchar)... and is exactly this last event which cause my trouble.
Two seconds ago, I find this method:
vector.capacity()
now I go to search documentation about in order to see if it can help me; do
you know if this method could be ad-hoc for my problem?
Thanks again
JFM
If you have control of the code that adds the data into the Vector,
change it to instead process it as a stream of rows! Many people find
it easier conceptually to deal with a Vector, however, often times you
can minimize memory requirements by changing your algorithms to
stream.
Well, hope this helps.
Daniel.
.
- Follow-Ups:
- Re: heap memory
- From: Andrea
- Re: heap memory
- References:
- heap memory
- From: Andrea
- Re: heap memory
- From: Daniel Pitts
- Re: heap memory
- From: Andrea
- heap memory
- Prev by Date: Re: heap memory
- Next by Date: Re: OS X 10.3.9 (or < 10.4) BufferedImage problem
- Previous by thread: Re: heap memory
- Next by thread: Re: heap memory
- Index(es):
Relevant Pages
|