Announcement

Collapse
No announcement yet.

File als BLOB in der DB Speichern?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • File als BLOB in der DB Speichern?

    Hallo,

    ich möchte eine Datei als BLOB in einer Oracle DB Speichern.
    <br><br>
    Wie löse ich das Problem in der Entity Bean? <br>
    Was für einen Datentyp muss ich dort verwenden? <br>
    Gibt es eine Art Stream-Objekt???<br>

    <bR>
    Danke im voraus!

    <br><br>
    Grüsse Tobi

  • #2
    Hi Tobias,

    bei CMP ist es von App.Server abhängig. Bei Bean-Managed-Persistence müßte es nach untem stehenden Bsp. funktionieren.

    .....
    .....

    String blobValue = "...";

    byte [] blobBytes = blobValue.getBytes ();

    PreparedStatement statement = connection.prepareStatement("INSERT INTO tableXY VALUES(?)");

    ByteArrayInputStream stream = new ByteArrayInputStream (blobBytes );

    statement.setBinaryStream (1, stream, blobBytes.length);

    statement.execute ();

    ....

    Cia

    Comment

    Working...
    X