@Test public void testgetAttach() throws Throwable{ FileOutputStream fos = new FileOutputStream("d:/temp.jpg"); postDao.getAttach(1,fos); }
public void getAttach(final int postId, final OutputStream os) { String sql = "SELECT post_attach FROM t_post WHERE post_id=? "; jdbcTemplate.query(sql, new Object[] {postId}, new AbstractLobStreamingResultSetExtractor() { protected void handleNoRowFound() throws LobRetrievalFailureException { System.out.println("Not Found result!"); } public void streamData(ResultSet rs) throws SQLException,IOException { InputStream is = lobHandler.getBlobAsBinaryStream(rs, 1); if (is != null) { FileCopyUtils.copy(is, os); } } } ); }
PostDao { public void getAttach(final int postId, final OutputStream os) { String sql = "SELECT post_attach FROM t_post WHERE post_id=? "; jdbcTemplate.query(sql, new Object[] {postId}, new AbstractLobStreamingResultSetExtractor() { protected void handleNoRowFound() throws LobRetrievalFailureException { System.out.println("Not Found result!"); } public void streamData(ResultSet rs) throws SQLException,IOException { InputStream is = lobHandler.getBlobAsBinaryStream(rs, 1); if (is != null) { FileCopyUtils.copy(is, os); } } } ); } }
PostDao { public void getAttach(final int postId, final OutputStream os) { String sql = "SELECT post_attach FROM t_post WHERE post_id=? "; jdbcTemplate.query(sql, new Object[] {postId}, new AbstractLobStreamingResultSetExtractor() { protected void handleNoRowFound() throws LobRetrievalFailureException { System.out.println("Not Found result!"); } public void streamData(ResultSet rs) throws SQLException,IOException { InputStream is = lobHandler.getBlobAsBinaryStream(rs, 1); if (is != null) { FileCopyUtils.copy(is, os); } } } ); }  }
PostDao { public void getAttach(final int postId, final OutputStream os) { String sql = "SELECT post_attach FROM t_post WHERE post_id=? "; jdbcTemplate.query(sql, new Object[] {postId}, new AbstractLobStreamingResultSetExtractor() { protected void handleNoRowFound() throws LobRetrievalFailureException { System.out.println("Not Found result!"); } public void streamData(ResultSet rs) throws SQLException,IOException { InputStream is = lobHandler.getBlobAsBinaryStream(rs, 1); if (is != null) { FileCopyUtils.copy(is, os); } } } ); }  @Autowired void setJdbcTemplate(JdbcTemplate jdbcTemplate); @Autowired void setLobHandler(LobHandler lobHandler); @Autowired void setIncre(DataFieldMaxValueIncrementer incre); void addPost(final Post post); void getNativeConn(); List<Post> getAttachs(final int userId); void getAttach(final int postId, final OutputStream os); }
PostDao { public void getAttach(final int postId, final OutputStream os) { String sql = "SELECT post_attach FROM t_post WHERE post_id=? "; jdbcTemplate.query(sql, new Object[] {postId}, new AbstractLobStreamingResultSetExtractor() { protected void handleNoRowFound() throws LobRetrievalFailureException { System.out.println("Not Found result!"); } public void streamData(ResultSet rs) throws SQLException,IOException { InputStream is = lobHandler.getBlobAsBinaryStream(rs, 1); if (is != null) { FileCopyUtils.copy(is, os); } } } ); }  @Autowired void setJdbcTemplate(JdbcTemplate jdbcTemplate); @Autowired void setLobHandler(LobHandler lobHandler); @Autowired void setIncre(DataFieldMaxValueIncrementer incre); void addPost(final Post post); void getNativeConn(); List<Post> getAttachs(final int userId); void getAttach(final int postId, final OutputStream os);  }