作成したデータベースのテーブルからすべてのフィールドをPDFに書き込もうとしています。データベースからPDFへのリストの書き込み
Document snapshot = new Document();
ArrayList<History> historyList = new ArrayList<History>();
Connection con = dbConnection();
String query = "SELECT * FROM apm_system.history";
Statement st;
ResultSet rs;
try {
st = con.createStatement();
rs = st.executeQuery(query);
History history;
while (rs.next()) {
history = new History(rs.getString("TransactionID"),
rs.getString("On"), rs.getString("By"), rs.getString("Date"),
rs.getString("Time"));
historyList.add(history);
}
PdfWriter.getInstance(snapshot, new FileOutputStream("snapshot.pdf"));
snapshot.open();
for (int i = 0; i < historyList.size(); i++) {
String temp = historyList.get(i).toString();
Paragraph p = new Paragraph(temp + "\n");
snapshot.add(p);
}
} } catch (Exception e) {
System.out.println(e);
}
snapshot.close();
私のPDFファイルは次のようになります:これは私のコードです
[email protected]
[email protected]
[email protected]
[email protected]
私のコードではなく、それはちょうどそれらを参照しています、データベースから実際のフィールドを書いていません。正しい用語を使用しているのではなく、出力するのではないかどうかはわかりません。ID32321 User Admin 2017/10/12 14:24 [email protected]をPDFに出力します。 これを修正するにはどうすればよいですか?前もって感謝します。
私のコードはデータベースからの実際のフィールドを書いているのではなく、単に参照しています。正しい用語を使用しているのではなく、出力するのではないかどうかはわかりません。ID32321 User Admin 2017/10/12 14:24 [email protected]からPDFに – HelloWorld
私は近い投票に同意しません(あなたが求めているものは不明です)。質問は非常に明確で、コード例を含み、期待された結果と実際の結果が含まれています。私のような開発者でなくても、その質問に答えることができるように、答えはそれほど簡単ではありません。 –