Czy ktoś mógłby pomóc jak zwrócić z serwera zdjęcie które jest w bazie danych (typu bytea) ?
Próbowałem coś takiego

@GET
	@Path("request=getTile")
	@Produces({"image/jpg"})
	public Response getTileGET(@QueryParam("id_photo")String id_photo,
						  @QueryParam("x")String x, 
						  @QueryParam("y")String y, 
						  @QueryParam("zoom")String zoom) throws SQLException, IOException  {
		
		BufferedImage BI = null;
		connection dbs = new connection();
		Statement statement = null;
	    Connection con = dbs.getConnection();
	    PreparedStatement ps = null;
	    
	    try {
	        ps = con.prepareStatement("SELECT image from tiles where id_photo = '"+id_photo+"' "
	        		+ "and x ='"+x+"' and y ='"+y+"' and zoom = '"+zoom+"';");

	        ResultSet rs = ps.executeQuery();
	        
	        	while (rs.next()) {
	        		InputStream input = rs.getBinaryStream("image");
	        		BI=ImageIO.read(input); 
	        		input.close();	
	        	}
	        
	    }     
	    catch (SQLException e )
	    {
	        e.printStackTrace();
	        System.out.println("Zle dane");
	    }
	    finally {
	        if (statement != null) {
	            statement.close();
	        }

	        if (con != null) {
	            con.close();
	        }
	    }		
	    return Response.ok(BI).build();
	}