title: Inserting an uploaded file to DB2 Clob using Spring Framework or general JDBC
body: <p>I am trying to upload a file to DB2 Clob column. I am getting the file from user using FormFile. This FormFile object is sent to DAO layer where it has to be inserted. My DAO layer logic is given below,</p>
  
  <pre><code>public int uploadRequestDocument(final int requestId, final FormFile requestFile, final String userId) throws EfoneException{
  int updatedRowCount = 0;
  String sqlQuery = Constants.GFONO_QUERY_ADD_GFONO_REQUEST;
  LobHandler lobHandler = new DefaultLobHandler();
  final InputStreamReader requestDocumentReader = new InputStreamReader(requestFile.getInputStream());
  
  updatedRowCount = getJdbcTemplate().execute(sqlQuery, new AbstractLobCreatingPreparedStatementCallback(lobHandler) {
  @Override
  protected void setValues(PreparedStatement stat, LobCreator lobCreator)throws SQLException, DataAccessException {
   stat.setString(1, "1");
   stat.setString(2, "Test");
   stat.setString(3, userId);
   stat.setString(4, userId);
   stat.setInt(5, requestId);
   lobCreator.setClobAsCharacterStream(stat, 6, requestDocumentReader, requestFile.getFileSize());
  }
  });
  </code></pre>
  
  <p>I tried the below options too but was not fruitful,</p>
  
  <pre><code>stat.setCharacterStream(6, requestDocumentReader, requestFile.getFileSize());
  stat.setCharacterStream(6, requestDocumentReader, MAX_SIZE);
  </code></pre>
  
  <p>I am always getting the below error message,</p>
  
  <pre><code>org.springframework.dao.DataIntegrityViolationException: 
  PreparedStatementCallback; SQL 
  [insert into GFONO.GFONO_REQUEST_DOC (rqst_doc_num, rqst_doc_loc_num, last_change_userid, create_userid, create_tmstp, last_change_tmstp, efa25_seq_num, rqst_doc)
  values (?,?,?,?,CURRENT TIMESTAMP, CURRENT TIMESTAMP, ?,?)];
  DB2 SQL error: SQLCODE: -302, SQLSTATE: 22001, SQLERRMC: null;
  nested exception is com.ibm.db2.jcc.a.SqlException: DB2 SQL error: SQLCODE: -302, SQLSTATE: 22001, SQLERRMC: null
  at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:101)
  </code></pre>
  
  <p>Please suggest on what I am missing and help me resolve this issue.
  Thanks in advance</p>