Harsha
Harsha

Reputation: 3578

Printing a MySql results set in java

How can we print the data of a mysql results set on the printer with correct alignments of each data rows and columns? Lets say, we get a dataset from a mysql database and populate that data in to a JTable, out of that JTable is there a way to get a printed hard-copy without any borders and lines of the JTable?

Upvotes: 0

Views: 502

Answers (2)

Costis Aivalis
Costis Aivalis

Reputation: 13728

Java has the System.out.printf method, which works like the printf of C with a format String and varargs.

I think for DB reports it is more convenient on the long run to use a Report Generator like iReport.

Upvotes: 1

Miserable Variable
Miserable Variable

Reputation: 28752

You need to pad each column with spaces and make it the same length as the column size.

Upvotes: 2

Related Questions