Java & MySQL, Printing

Hi Experts,

I have a MySQL table which I have written a Java Application to add, navigate and (am currently working on) delete records. However, I would also like to add print function but am unsure how to do this.

Image I have a table wtih 4 fields:

User_First _Name
User_Second_Name
User_Branch
User_Department

I understand how to create an SQL query to find the relevant records requested. My problem is 2 fold but associated:

1. How do I ensure that the output when it is printed does not scroll off the end of my screen, for example, if My screen could display say 50 lines and the number of records returned was 75, how could I stop the page from scrolling off after line 51?
2. How do I create a report in Java, perhaps with a print preview option, with the same critieria as #1, i.e make sure the report stays on the page and has headers and footers etc.?

I'm guessing these should be possible but I cannot find anything on this on the net so would be grateful for any advice, links or whatever.

Thanks.
MushyPeezeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

FesterWimCommented:
I suggest you use JFreeReport: http://www.jfree.org/jfreereport/

It is quite easy to create a report that way with headers and footers. You can also easily have a print preview. I already used this in a project of mine.

Another option is to convert your output to XML, then do an XSLT-FO transformation and use FOP to create a PDF. You can then use Acrobat Reader as print preview. But I would not recommend this option since you're not starting from XML anyway.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mudriCommented:
why don't you control what will be displayed by limiting number of rows that mysql will return, i.e.:

SELECT * FROM workers LIMIT 50 OFFSET 0;
SELECT * FROM workers LIMIT 50 OFFSET 50;
 . . .

0
gdrnecCommented:
Jasper is also a good alternative.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.