i have one problem to retrive data by row vise in new page from database and it will also keep null value space when it will printing. please help me so display data without null (space) and also row vise.

If you've tried, show what you tried and where you failed.
If you've not tried, try.

import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;

import java.io.FileOutputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Vector;

import javax.swing.JOptionPane;
import java.awt.*;
import javax.swing.*;

public class addDatabaseInTable {


    public static void main(String[] args) {

        Document d = new Document();

        try {



             PdfWriter.getInstance(d,new FileOutputStream("c:/temp/gemi.pdf"));

             d.open();
             PdfPTable table = new PdfPTable(4); // 3 columns.

            PdfPCell cell1 = new PdfPCell(new Paragraph("LabName"));
            PdfPCell cell2 = new PdfPCell(new Paragraph("Reading1"));
            PdfPCell cell3 = new PdfPCell(new Paragraph("Reading2"));
            PdfPCell cell4 = new PdfPCell(new Paragraph("Reading3"));

            table.addCell(cell1);
            table.addCell(cell2);
            table.addCell(cell3);
            table.addCell(cell4);


            PreparedStatement pst;

            String id;

            Class.forName("com.mysql.jdbc.Driver");
            Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/reading","root","root");
            Statement st = con.createStatement();
            pst = con.prepareStatement("select * from content");
            ResultSet rs = pst.executeQuery();
            int i = 0;
            Vector v = new Vector();
            while (rs.next())
            {
                id= rs.getString(1);

                v.add(id);

               String  labid = rs.getString("labid");
               String  r1 = rs.getString("r1");
               String  r2 = rs.getString("r2");
               String  r3 = rs.getString("r3");



                System.out.println(labid);
                System.out.println(r1);
                System.out.println(r2);
                System.out.println(r3);

                breakloop:
                  do
                  {
                    i++;
                      System.out.println("new");
                      d.add(table);
                      d.newPage();

                      break breakloop;
                  }
                  while(i<1);

                table.addCell(labid);
                table.addCell(r1);
                table.addCell(r2);
                table.addCell(r3);


            }

           d.add(table);




            d.close();
        } catch(Exception e){

        }
    }
}

Never do this when writing new code:

} catch (Exception e) {
}

If/when there is an error you just told Java that you didn't want to know anything about it, and please discard the detailed error message that Java just created for you.
ALWAYS put an e.printStackTrace(); in your catch blocks until/unless you have a good reason to do something else.

yes. You have to use "e.printStackTrace();" in your catch block.
And check the table column names of the "content" table.
e.g. labid, r1, r2, r3

String labid = rs.getString("labid");
String r1 = rs.getString("r1");
String r2 = rs.getString("r2");
String r3 = rs.getString("r3");

You have to use 'column names of content table' in rs.getString("xxxx");

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.