Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PrintWriter Problem?

 
Gregory Thomas
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using PrintWriter to output the results of my query that has 6,000 records. It properly inserts them into the database but not outputting to a text file. It stops printing the results at about 5000 out of the 6000 rows (records).

...
StringBuffer insertBfr = new StringBuffer();
insertBfr.append("INSERT INTO x_table VALUES (").append( so forth....

logfile.println(insertBfr.toString());

Is there a limit on how much data I could output using the PrintWriter class?

Thanks in advance.
 
Henrique Sousa
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gregory,
It seems to me that you are printing the whole file in a single println(...) statement, is that right? If this is the case, I suggest you split it so that you print each sql insert statement at a time (you probably have a for loop, so it is not a big change). Two advantages on that approach: memory saving -- no huge StringBuffer walking around -- and it would be easier to find out why the file isn't fully written.
That might solve the problem also, but it is just an assumption.
 
Gregory Thomas
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henrique...Thank you for your fast reply. Yes, it is in a loop. I will try your suggestion and will post the results after my run. Thank you again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic