Youssef57245577
Youssef57245577

Reputation: 1

Persiste image file as byte[] on db2

I'm using Spring framework & DB2 as database i have an entity with image field annotated as follow

@Lob
@Type(type="binary")
private byte[] image;

or

@Lob 
@Basic(fetch=FetchType.LAZY)
@Column(name="image",columnDefinition="MEDIUMBLOB")
private byte[] image;

this not work for db2 and it's return :

Caused by: com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -302, SQLSTATE: 22001, SQLERRMC: null

Using MySQL i have never seen this error before.

Please help

Upvotes: 0

Views: 173

Answers (1)

javaguest
javaguest

Reputation: 399

According to this question:

SqlException: DB2 SQL error: SQLCODE: -302, SQLSTATE: 22001, SQLERRMC: null

SQL code -302 means the column in DB2 is too small. Try changing to a bigger BLOB data type.

Upvotes: 0

Related Questions