code: public static void writeKML(Connection connection, String fileName, String tableReference) throws SQLException, IOException {
          KMLDriverFunction kMLDriverFunction = new KMLDriverFunction();
          kMLDriverFunction.exportTable(connection, tableReference, URIUtilities.fileFromString(fileName), new EmptyProgressVisitor());
      }
docs: This method is used to write a spatial table into a KML file
  @param connection
  @param fileName
  @param tableReference
  @throws SQLException
  @throws IOException