// Получаем результаты
final Collection<Notelist> results =
Note.getResultNote();
try {
// Записываем результаты в файл
NoteWriter.writeResults(fileName, results);
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
System.exit(-1);
} catch (XMLStreamException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
System.exit(-1);
}
} catch (SQLException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
System.exit(-1);
}
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package voen;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Collection;
import java.util.LinkedList;
/**
*
* @author Drugmon
*/
public class Note {
public static Collection<Notelist> getResultNote()
throws SQLException {
final Collection<Notelist> results = new LinkedList<Notelist>();
final Connection c = ConnectionBase.getConnection();
try {
Statement stmt = c.createStatement();
try {
final String query =
"select name, dt_birth, text, dt_note from people , medical_notes where person_id=people.id and people.id=5";
stmt.executeQuery(query);
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
results.add(new Notelist(
rs.getString("name"),
rs.getString("dt_birth"),
rs.getString("text"),
rs.getString("dt_note")
));
}
} finally {
stmt.close();
}
} finally {
c.close();
}
return results;
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package voen;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Collection;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
/**
*
* @author Drugmon
*/
public class NoteWriter {
public static void writeResults(
final String fileName,
final Collection<Notelist> results) throws IOException, XMLStreamException {
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.