I'm working with some databases and I need to print each database in files. My Server has 5 GB of RAM and I assigned 4GB just for tomcat server.
I made a simple resultset that consult all the rows of each database. Then I print each row in a file (.dat) (Obviously I do that separately)
I can work with an entire result set that has 5738095 rows
But if I want to work with a database with more than 7 millions of rows I got the error "Java heap space", I've started with 3GB and 2GB for tomcat but when I started working with more than 3 millions of rows I needed to add more RAM to my server, so my question here is, is it good to put more RAM to my server or how can I divide the result set and print million per million without get the error " java heap space".
I've been thinking in count the entire database and make something like limit 0 offset 1000000, limit 1000000 offset 1000001, but sincerely I'm lost. Thanks for reading and helping and sorry for my english.
There's some code
//numero columnas is the total of columns
 rs_datos =  StDatos.executeQuery("select * from table");
  while(rs_datos.next())
  {
    for(int i = 0; i < numeroColumnas; i++)
    {
      if(i+1 == numeroColumnas)
      {
       pw.print(rs_datos.getString(i+1));
      }
      else
      pw.print(rs_datos.getString(i+1) + "|");
    }
     pw.println("");
  }
  pw.close();
 
     
     
     
     
     
     
    