-3

JSFだけのPrimefacesを使用して、PDFファイルをデータベースにアップロードするコードを実装する方法を教えてください。エンティティ プロパティは BLOB です。

属性、

ディエゴ・サビーノ

4

1 に答える 1

0

最も簡単なアプローチは、この例を見ることです

Prime Faces ファイルの例

これにより、File オブジェクトが得られます。

次に、これをデータベースに保存できます

//saving the image
            PreparedStatement psmnt = (PreparedStatement)    con.prepareStatement("INSERT INTO DB.images VALUES(?,?)");
            psmnt.setInt(1, 5);
            psmnt.setBlob(2, new FileInputStream(fileFromEvent), fileFromEvent.length());
            psmnt.executeUpdate();
            System.out.println("Image saved in DB");
于 2013-05-16T18:01:04.750 に答える