Spring JdbcTemplate - Insert blob and return generated key

后端 未结 11 1863
猫巷女王i
猫巷女王i 2020-12-15 06:06

From the Spring JDBC documentation, I know how to insert a blob using JdbcTemplate

final File blobIn = new File(\"spring2004.jpg\");
final InputStream blobIs         


        
11条回答
  •  孤街浪徒
    2020-12-15 06:16

    I got the same issue to update blob data -- need to update image into database. than i find some solution as below. for more details update image into database

     LobHandler lobHandler = new DefaultLobHandler();
     statusRes = jdbcTemplate.update("update  USERS set FILE_CONTENT = ?, FILE_NAME = ? WHERE lower(USER_ID) = ?",
                   new Object[] {new SqlLobValue(image, lobHandler),fileName,userIdLower},
                   new int[] {Types.BLOB,Types.VARCHAR,Types.VARCHAR});
    

提交回复
热议问题