2

私の英語で申し訳ありません。私は翻訳機を使う。Javaへのコードがあります。フィールドのデータベースから Posgresql bytea バイナリ データを読み取り、ファイルに保存します。

<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>

ダウンロードするファイルを Xpages でユーザーに転送する方法。ダウンロード後、削除してください。

4

1 に答える 1