Retrieve an Image stored as BLOB on a MYSQL DB

前端 未结 4 720
挽巷
挽巷 2020-11-27 16:37

I\'m trying to create a PDF based on the information that resides on a database. Know I need to retrieve a TIFF image that is stored as a BLOB on a mysql database from Java.

4条回答
  •  [愿得一人]
    2020-11-27 17:21

    private void loadFileDataBlobFromDataBase()
                 {
                List bFile = jdbcTemplate.query(sql, new RowMapper() {
                    @Override
                    public Blob mapRow(ResultSet rs, int rowNum)
                            throws SQLException {
                        return rs.getBlob(1);
                    }
                });
                if (bFile != null && bFile.size() > 0) {
                    bufReader = new BufferedReader(new InputStreamReader(bFile.get(
                            0).getBinaryStream()));
                }
                if (null != bufReader) {
                    dataVO record = null;
                    String lineStr = bufReader.readLine();
                    record = (dataVO) lineMapper.mapLine(lineStr, 1);               
                }
            }
        }
    

提交回复
热议问题