trying to insert image into database getting ORA-01460: unimplemented or unreasonable conversion requested error

前端 未结 1 1072
-上瘾入骨i
-上瘾入骨i 2021-01-24 17:35

I\'m trying to insert an image into database and with auto increment photo_id.

my table columns are:

PHOTO_ID  (primary key),
USERNAME  (fkey),
PICTURE,         


        
相关标签:
1条回答
  • 2021-01-24 18:00

    InputStream.available() does not return the size of the stream (which is clearly documented in the Javadocs).

    You will need to query the size of the file, not the "available bytes" in the inputstream:

    ps.setBinaryStream(2, fis, (int)file.length());
    

    depending on the version of your JDBC driver you can also use

    ps.setBinaryStream(2, fis, file.length());
    

    But setBinaryStream(int, InputStream, long) is defined in JDBC 4.0 and thus not implemented by all driver versions. setBinaryStream(int, InputStream, int) is JDBC 2.0 (if I'm not mistaken) and should be available in all versions.

    0 讨论(0)
提交回复
热议问题