• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

out of memory error

 
Pinik Tilli
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I would be glad if someone could provide me any solution for this error.
I am trying to execute the SQL query for the table which consists of morethan 2 millions of rows. And i am using CachedRowSetImpl()to populate the resultset and use this object later for retreiving the details. But when i am trying to populate outofmemory error is obtained.

Any other suggestions are acceptable.

working Env:
jdeveloper 10g for development
oracle 10g for database

Below is the code:

public boolean getDataFromDB(Connection conn, String sqlQuery,
Map parameters) throws CDaoException {

PreparedStatement prepStmt = null;
ResultSet rs = null;
StringBuffer sql = new StringBuffer();
String value = null;
int a =0;

try {

sql.append(sqlQuery);
prepStmt = conn.prepareStatement(sql.toString());

if( parameters != null ){
// set the parameters for query
for( int i=0 ; i < parameters.size() ; i++){
a = i+1;
if( parameters.containsKey(a) ){
value = (String)parameters.get(a);
prepStmt.setString(a,value);
}
}
}

rs = prepStmt.executeQuery();

crs = new CachedRowSetImpl();
crs.populate(rs); // Error is obtained at this statement.

conn.close();
return true;

} catch (SQLException e) {
throw new CDaoException("\n Error preparing SQL statement: " + sqlQuery + " \n Please enter the correct SQL statement");
}
} // end public boolean getDataFromDB(Connection conn, String sqlQuery,Set parameters) */

Thanks once again.
 
Joshy Thomas
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is your query like ? Are you getting all 2 million records in one query ?.
 
Pinik Tilli
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The SQL Query is select * from DP_MASTER_ACTIVE.
when this query is executed i get morethan 2million of records.
Please provide the solution.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are two approaches to this:

1. Provide the JVM with enough memory to store all two million records.

2. Redesign your application so that you don't have to have all two million records in memory at once.

If #1 is impossible then you will have to use #2.

(I don't know what environment this code is running in so it's hard to say how to provide more memory.)
 
seshu Palamanti
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pinik Tilli
You can use setPage to the CacheRowSetImpl to set the number of rows to include at a particular time.So you should not fine with that out of memory thing for now.
 
Serkan Demir
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pinni,
May i learn your starting heap size?
 
Pinik Tilli
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for all valuable suggestions.

Coming to heap size , both max and min is set to 512M.
MaxPermSize is set to 160M.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic