File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes PrintWriter Problem? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "PrintWriter Problem?" Watch "PrintWriter Problem?" New topic
Author

PrintWriter Problem?

Gregory Thomas
Greenhorn

Joined: Jun 01, 2004
Posts: 11
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

Joined: Apr 29, 2004
Posts: 92
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.


Henrique Sousa<br />SCJP 1.4<br /> <br />All men die, not all men really live - Braveheart, 1995
Gregory Thomas
Greenhorn

Joined: Jun 01, 2004
Posts: 11
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PrintWriter Problem?
 
Similar Threads
how to give the link to the result which are executed by query
How to set the link the results which are available in the database
How to handle DOJO response in json format
Servlet output into JSP template
Converting a String to Proper Case