I am sorry for my English. I use a translator. There is a code to Java. Reads from the database of the field Posgresql bytea binary data and stores it in a file:
<code>
public static void saveToFile() throws IOException {
try {
Connection conn = JdbcUtil.getConnection(FacesContext.getCurrentInstance(), "derby1");
ResultSet rs = conn.createStatement().executeQuery(
"SELECT files FROM test_goverment where who='d'");
byte[] imgBytes = null;
if (rs != null) {
while (rs.next()) {
imgBytes = rs.getBytes(1);
}
FileOutputStream os = new FileOutputStream("c:\\samoutput.txt");
os.write(imgBytes);
os.flush();
os.close();
}
rs.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
enter code here}
}
</code>
How to transfer the file to download to user in Xpages. And remove it after downloading.