Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OutOfMemoryError at the time of batch run

 
akshit indra
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a batch file which gets transferred by a batch run.Data from batch file are read and then a match is done to insert data into database.
Sample data(from batch file):
12,234,asd,3456,asv,sdas,asdase,sas,awer
..............................................................(96253 lines)
Earlier a class was used to parse first 4 data(ie 12,234,asd,3456)and then a match was made to enter these data into database.
Code has been written in a fashion to read data using stringTokeniser and nextToken().
Now I need to read last data in each line and then I have to do a match through database and proper translation is done and finnaly I have to enter translated data for it.(awer=>translatedkey;and then translatedkey into Databaase)
I used the same coding pattern and read last data (token by token using nextToken()) and it has worked fine in test environment which has only 300 lines.but problem arises when the same batch(class run in production which has big file 96253 lines)
The issue :
Exception in thread "main" java.lang.OutOfMemoryError:
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)

Please help me to find the issue and solution too.

NOTE:I thought since data are read token by token; that might have causes the issue. so I tried to read direct last data of each line using
String result =s.substring(s.lastIndexOf(',')+1, s.length());//but it did not work as the other codes have been written in
a manner to give data token by token. so instead of getting awer I get asv

can I use

s.nexttoken();s.nexttoken(); and s.nexttoken(); to read last column


TIA
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic