Exceeding the memory size !!!!!

I've written the code, but it is exceding the memory size. Could anyone tell me how to get rid of this exception.....

The code is as follows....

if(export_data.equals("ex")){

PrintWriter out = response.getWriter();

try{

response.setContentType("applicaton/download");

response.setHeader("Content-Disposition","attachment; filename=data.txt");

//rs = stmt.executeQuery("select * from PHONE_NUMBERS_LIST order by PHONE_NUMBER");

rs = stmt.executeQuery("select PHONE_NUMBER,MIN(PHONE_MODEL),MIN(MANUFACTURER) FROM PHONE_NUMBERS_LIST GROUP BY PHONE_NUMBER");

//around 33 laks data

while(rs.next()){

out.write(rs.getString(1).trim());

out.write("\t");

out.write(rs.getString(2).trim());

out.write("\t");

out.write(rs.getString(3).trim());

out.write("\r\n");

}

out.close();

}catch(Exception e){

System.out.println("This is in exporting the file"+e);

}

The data is more (around 33 laks). So, what should i do for this. How to get rid of this , please help me out in this regard.... The exception i'm throwing is:

This is in exporting the filecom.microsoft.sqlserver.jdbc.SQLServerException: The system is out of memory. Use server side cursorsfor large result sets:Java heap space. Result set size:104,167,523. JVM total memory size:66,650,112.

The problem is for size only.... Please tell me how to design this code to evade from this exception......

in advance thanks......

[2168 byte] By [Navneet_Singha] at [2007-11-26 22:12:34]
# 1
You didn't post this code, but are you using a scrollable result set?Don't do that, it's unnecessary. Forward-only is exactly what you are doing, so use that.
DrClapa at 2007-7-10 11:02:06 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

thanks for this reply...

no i'm not using scroll resultset. i've written the code as:

Statement stmt = con.createStatement;

ResultSet rs = null;

....

...

rs = stmt.executeQuert("");

........

i'm still not able to get it. Please tell me how to do this problem resolved. It's a very big data, so it's not able to put it into the memory. Could u please tell me how to get rid of this problem. Please tell me where to put the code or some other hint to evade from this problem.

Navneet_Singha at 2007-7-10 11:02:06 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
i want to download the file from the database through the ResultSet (accessing each value and writing it into the file). In that case what should i do to get rid of this vaery large ResultSet dialemma. Please help me out in this regard....
Navneet_Singha at 2007-7-10 11:02:06 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4
Read the error message!Either use server-side cursors, or allocate more memory to your JVM.
bckrispia at 2007-7-10 11:02:06 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5

> i want to download the file from the database through

> the ResultSet (accessing each value and writing it

> into the file). In that case what should i do to get

> rid of this vaery large ResultSet dialemma. Please

> help me out in this regard....

See the following link for -Xmx

http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html

jschella at 2007-7-10 11:02:06 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6
Increase the heap size to max and try running it
subbaraj78a at 2007-7-10 11:02:06 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...