title: Create Word Document with Java
body: <p>I have default table model fetch with data from database and i want to print in doc word as a table. How to achieve that. See the code below:</p>
  
  <pre><code>    try {
          try {
              con = connCC.getDBconnection();
               } catch (ClassNotFoundException ex) {
                Logger.getLogger(CustomerSR.class.getName()).log(Level.SEVERE, null, ex);
          }
          stm = con.createStatement();
          ResultSet rs = stm.executeQuery("Select * From Appointment");
  
          while (rs.next()) {
  
              for (int col = 0; col &lt; 1; col++) {
                  rowData.add(rs.getString(1));
                  rowData.add(rs.getString(2));
                  rowData.add(rs.getString(3));
                  rowData.add(rs.getString(4));
                  rowData.add(rs.getString(5));
              }
              model.addRow(rowData);
          }
              window.display(model);
             //window.display(names, phones, addresses);
          } catch (SQLException ex) {
            ex.printStackTrace();
      }
  
  }
  </code></pre>