Displaying Images stored in Database

Hi, all i am having images stored in Databases as BLOB.
how i can display that in flex application. suppose i am having the ArrayList of Employees in which employee object also have a field of called empImage, how i can display this data in flex.
i am using BlazeDS.
Thanks
Regards
Amar Deep Singh

Hi,
This will give you the idea of getting the image from you array list.
http://blog.flexexamples.com/2008/02/15/creating-a-simple-image-gallery-with-the-flex-hori zontallist-control/
Johnny
Please rate my answer. Tks

Similar Messages

  • Getting image stored in database !!

    Hey !!
    I'm really trying to solve so much problems i'm having with javafx !!
    So, like the title may suggest, i'm having problems as to get image from the database !!
    Everything seems fine but it tells me that there is "Exception while runing Application"
    here is the code !!
    @James D, i will come back bugging yu again to see how to use the stored images and display them inside the combobox and to render them ^^
    I haven't well understand how well as to use the enum struc in which yu declared the composed <Image,String> type ^^
    import java.awt.image.BufferedImage;
    import java.io.ByteArrayInputStream;
    import java.io.InputStream;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import javafx.application.Application;
    import javafx.event.Event;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.ComboBox;
    import javafx.scene.image.Image;
    import javafx.scene.image.ImageView;
    import javafx.scene.layout.StackPane;
    import javafx.stage.Stage;
    import javax.swing.JOptionPane;
    * @author Minedun6
    public class DynamicCustomComboBox extends Application {
        Connection c = connection.ConnecrDb();
       PreparedStatement pst = null;
       ResultSet rs = null;
       ComboBox box1;
       ImageView view;
        @Override
        public void start(Stage primaryStage) {
            box1 = new ComboBox();
            box1.setPrefSize(100, 25);
            box1.setOnShowing(new EventHandler() {
                @Override
                public void handle(Event t) {
                    box1.getItems().clear();
                    try {
                String sql = "select libelle_constr,img_constructeur from constructeurs where libelle_constr='Citroen';";
                pst = c.prepareStatement(sql);
                rs = pst.executeQuery();
               while(rs.next()){
                   box1.getItems().add(rs.getString("libelle_constr"));
                   InputStream input = new ByteArrayInputStream(rs.getBytes("img_constructeur"));
                   Image imge = new Image(input);
                   view.setImage(imge);
            } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e);
            StackPane root = new StackPane();
            root.getChildren().addAll(box1);
            Scene scene = new Scene(root, 300, 250);
            primaryStage.setTitle("Hello World!");
            primaryStage.setScene(scene);
            primaryStage.show();
        public static void main(String[] args) {
            launch(args);
    }

    In any real application, it's a mistake to mix your presentation (user interface) code with your persistance (database access) code.
    Why? You want maintainability, flexibility, and testability.
    Maintainability:
    Suppose you want to change the structure of your database. E.g. the database admin (which may be you, or someone else) determines that the database design you have is inefficient and needs to be changed. If your database code is scattered over the whole application, mixed in among your user interface code, tracking down what needs to be changed will be a nightmare. If all your database code is in a single class, or perhaps a set of classes in a single package, then the updates are localized and much easier to manage. Furthermore, you can build the new database access code on its own, test it out, and then when you are sure it works just switch your user interface code to use the new persistance layer instead of the old one. The same applies if you decide you're going to use a completely different technology to store the data; perhaps you want to use something like Hibernate instead of plain JDBC, or maybe you decide you want to make the data accessibile via a web service.
    Flexibility:
    What if you (or, more likely, your manager) decides they're going to change to a new user interface technology. Maybe they decide to switch to a web application (i.e. HTML-based) instead of a desktop application. You obviously need to rewrite the user interface code, but you should be able to keep all the database access code you've written. If your database access code is all jumbled up with the user interface code you're replacing, it's going to be way harder to reuse that code. If the two are separated out, you just build a new user interface in whatever new technology you're using, and access the same class(es) you used for your database access without touching them.
    Testability:
    This whole thread is actually a demo of how testability is much harder if you don't properly separate your code. You posted "getting image stored in database", thinking that was your problem. It wasn't; your problem was actually an error in the way you'd set up your JavaFX code. Because the two were completely mixed together, it was hard to know where the error was. The error you had was actually a really simple one; it would have been much easier to see if you had simpler, properly separated code; but because you didn't organize your code like that it took you days to figure out the problem. This was only a couple of dozen lines of code; imagine how this looks in a real application with hundreds or thousands of classes.
    The point is that decisions about how to access your data (standalone database, web service, or EJB?; plain JDBC, JPA, Hibernate, etc?) , and decisions about the presentation technology (desktop or web? JavaFX or Swing?, or Servlets/JSPs, JSF, Swing MVC, or any of a huge number of frameworks) are completely independent. You should be in a position to change those decisions - to redesign aspects of the application - with the least amount of effort possible. Failing to properly design things will make this much harder, or likely completely impossible.
    These are real concerns that affect every application that goes into production.
    Even if you're just making a small application, it will benefit you to set things up correctly from the outset.

  • Displaying images stored in SQL Server

    Is there someway of displaying images stored within SQL
    Server. Is FDS required? Prefer a method to display images without
    using FDS; Web Service would be okay if that can work

    I do that sort of thing using PHP and mySQL the binary part
    of the image is stored in a BLOB field (Binary Large OBject) along
    the rest of the information necessary for the http headers (e.g.
    mime type, file name, file size) being staored in their own fields.
    That info is then used to build the file using PHP. The PHP
    file contains a mySQL query whos result is echoed with the
    appropriate headers. The URL points at the PHP file rather than at
    any saved image.
    Here's the php:
    <?
    # display_imagebank_file.php
    # Note: the ID is passed through the url e.g.
    # this_files_name.php?id=1
    # connect to mysql database
    mysql_connect('HOST', 'USERNAME', 'PASSWORD');
    mysql_select_db('DATABASE');
    # run a query to get the file information
    $query = mysql_query("SELECT FileName, MimeType, FileSize,
    FileContents FROM blobTable WHERE ID='$id'");
    # perform an error check
    if(mysql_num_rows($query)==1){
    $fileName = mysql_result($query,0,0);
    $fileType = mysql_result($query,0,1);
    $fileSize = mysql_result($query,0,2);
    $fileContents = mysql_result($query,0,3);
    header("Content-type: $fileType");
    header("Content-length: $fileSize");
    header("Content-Disposition: inline; filename=$fileName");
    header("Content-Description: from imagebank");
    header("Connection: close");
    echo $fileContents;
    }else{
    $numRows = mysql_num_rows($query);
    echo "File not found <br>";
    echo $numRows;
    echo " is the number of rows returned for id = ";
    echo $ID;
    ?>
    Hope that helps
    Phil

  • Display image stored @ content managemenbt

    Hi,
    this is regarding to displaying image stored @ content management, using <html:img> tag in .jsp
    under a node i am uploading two images. (node having two upload options)
    in .jsp i am using <html:img> tag to display the images.
    i tried to display both the images. But the first image what i upload is not showing. what i upload second is displaying.
    pls let me know how to resolve this.
    Thanks.

    You need to access binary property values separately from the node. In 9.2 the API is accessed via INodeManager.getStream(). Alternatively you can take advantage of the tags we have for this as well. Take a look here on edocs:
    http://e-docs.bea.com/wlp/docs92/cm/developCM.html
    -Ryan

  • Reading & displaying image in non-database item.

    Upto now I have read & displayed image in database block and items. It has few problems.
    Is there any way that I can read & display image in non-database block & items?
    Thanks and regards,
    Vikas

    <p>Have a look at this Java Bean.</p>
    Francois

  • Display images stored in the database

    I have images stored in the databse. I followed the steps provided in the oracle documentation. Now i want to retrive the image from the database into a java object that can be dislayed in , say, a JLabel. I am able to retrieve the image from the database into the OrdImage in the oracle.java.ord package and view the properties of the image. But unable to retrive the image as such to be displayed.
    Thanking You
    vinay

    This might help...
    import javax.imageio.*;
    import javax.imageio.stream.*;
    import javax.swing.*;
    import java.awt.*;
    import java.sql.*;
    import java.io.*;
    import oracle.jdbc.driver.*;
    import oracle.sql.* ;
    import oracle.ord.im.*;
    import java.awt.event.*;
    public class HelloDBImage implements ActionListener{
    OracleConnection con = null;
    JLabel label = null;
    String textFieldString = "Image ID entered";
    public void actionPerformed(ActionEvent e)
    String prefix = "You typed \"";
    if (e.getActionCommand().equals(textFieldString))
    JTextField source = (JTextField)e.getSource();
    ImageIcon imgIcon = createImageIcon(source.getText());
    if (null != imgIcon)
    // Create image Label
    label.setText(null);
    label.setIcon(imgIcon);
    else
    label.setIcon(null);
    label.setText("Image not found! ");
    source.setText("");
    label.repaint();
    //actionLabel.setText(prefix + source.getText() + "\"");
    public ImageIcon createImageIcon(String key)
    Image image = null;
    ImageIcon imgIcon = null;
    try
         // Connect to the database if necessary
    if (null == con) con = connect();
    // Create Input Stream from DB image.
    InputStream is = new BufferedInputStream(
    getDBInputStream(con, key));
    if (null != is)
    // Create Image from Image Input Stream
    ImageInputStream iis = ImageIO.createImageInputStream(is);
    image = ImageIO.read(iis);
    // Create Image Icon from ImageInputStream
    if (null != image) imgIcon = new ImageIcon(image);
    } catch (Exception e)
    System.out.println("exception raised " + e);
         e.printStackTrace();
    return imgIcon;
    public Component createPanelAndContents(String key)
    // Create the image label
    ImageIcon imgIcon = createImageIcon(key);
    if (null != imgIcon)
    // Create image Label
    label = new JLabel(imgIcon);
    else
    label = new JLabel("Image not found! ");
    // Create layout
    GridBagLayout gridBag = new GridBagLayout();
    // Create panel to draw in
    JPanel pane = new JPanel();
    pane.setLayout(gridBag);
    GridBagConstraints c = new GridBagConstraints();
    JScrollPane scrollPane = new JScrollPane(label,
    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
    JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;
    gridBag.setConstraints(scrollPane, c);
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.HORIZONTAL;
    scrollPane.setMinimumSize(new Dimension(300, 300));
    pane.add(scrollPane, c);
    // Add a text field and label to get anoter image
    JTextField textField = new JTextField(10);
    textField.setActionCommand(textFieldString);
    textField.addActionListener(this);
    // Add fields for input
    JLabel promptLabel = new JLabel("Please enter DB key: ");
         pane.add(promptLabel);
    pane.add(textField, c);
    return pane;
    public static void main(String[] args)
    String key = "1";
    try
    UIManager.setLookAndFeel(
    UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (Exception e) { }
    //Create the top-level container and add contents to it.
    JFrame frame = new JFrame("SwingApplication");
    HelloDBImage app = new HelloDBImage();
    if ((args.length > 0) && (args[0] != null)) key = args[0];
    System.out.print("length= " + args.length + "/" );
    if (args.length > 0) System.out.println(args[0]);
    Component contents = app.createPanelAndContents(key);
    frame.getContentPane().add(contents, BorderLayout.CENTER);
    //Finish setting up the frame, and show it.
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    frame.pack();
    frame.setVisible(true);
    public InputStream getDBInputStream(OracleConnection con, String key)
    InputStream is = null;
    try
         int index = 0;
         Statement s = con.createStatement();
         OracleResultSet rs =
         (OracleResultSet)s.executeQuery("select * from images " +
    "where item_id = " + key );
         if (rs.next()) // Just get first image if more than 1.
         index = rs.getInt(1);
         OrdImage imgObj =
    (OrdImage) rs.getCustomDatum(2, OrdImage.getFactory());
    is = imgObj.getContent().getBinaryStream();
    catch(Exception e)
    System.out.println("exception raised " + e);
    e.printStackTrace();
    return is;
    public OracleConnection connect() throws Exception
    String connectString;
    Class.forName ("oracle.jdbc.driver.OracleDriver");
    connectString = "jdbc:oracle:oci8:@orcl";
    OracleConnection con = (OracleConnection)
    DriverManager.getConnection(connectString,"scott",
                        "tiger");
    con.setAutoCommit(false);
    return con;

  • How to display Images stored in a database using javascript

    Hi.
    I have some images stored in a table and I need to display them using javascript. The images are stored in BLOB columns: I would like to know if I can put them on a directory and then get it from there using BFILENAME function.
    Any suggestion?
    Regards,
    Jeannine

    Hi All,
    Yes DuraiRaja - i am using the document.getElementById(' ').
    In my app, I have a Main controller calling a View - Default.HTM,
    This Default.HTM, in turn loads up three trays T1, T2, T3 and these tray elements in turn call up the controllers ctrl1, ctrl2, ctrl3 associated to them.
    CTRL1 calls a view - View1 - V1.htm, which has the below code.
    And on the below page all that i am trying to do is validate if "FieldVal" is blank or not.
    I get an error on IE as "Object required"
    I get a HTTP 501/505 error when i try to upload the code.
    Thanks all !

  • Problems displaying images stored in SQL Server as Datatype "image"

    I am trying to display an Image stored in SQL Server as
    datatype
    'image' and it only shows a portion of the image.
    It seems to be tied to the size (kb) of the image since the
    larger the
    image the less of it is shown before it cuts off(sometimes it
    cuts off
    mid line so it's about the file size and not fitting the
    image on the
    screen).
    Here is the code I am using that deals with the image.
    [Bindable]
    public var theImage:ByteArray = new ByteArray;
    private function getScans_result(event:ResultEvent):void{
    var imageByteArray:ByteArray = event.result[0].Image;
    theImage = imageByteArray
    <mx:Image id="theIMG" width="160" height="220"
    source="{theImage}"/>
    Any Thoughts??

    I do that sort of thing using PHP and mySQL the binary part
    of the image is stored in a BLOB field (Binary Large OBject) along
    the rest of the information necessary for the http headers (e.g.
    mime type, file name, file size) being staored in their own fields.
    That info is then used to build the file using PHP. The PHP
    file contains a mySQL query whos result is echoed with the
    appropriate headers. The URL points at the PHP file rather than at
    any saved image.
    Here's the php:
    <?
    # display_imagebank_file.php
    # Note: the ID is passed through the url e.g.
    # this_files_name.php?id=1
    # connect to mysql database
    mysql_connect('HOST', 'USERNAME', 'PASSWORD');
    mysql_select_db('DATABASE');
    # run a query to get the file information
    $query = mysql_query("SELECT FileName, MimeType, FileSize,
    FileContents FROM blobTable WHERE ID='$id'");
    # perform an error check
    if(mysql_num_rows($query)==1){
    $fileName = mysql_result($query,0,0);
    $fileType = mysql_result($query,0,1);
    $fileSize = mysql_result($query,0,2);
    $fileContents = mysql_result($query,0,3);
    header("Content-type: $fileType");
    header("Content-length: $fileSize");
    header("Content-Disposition: inline; filename=$fileName");
    header("Content-Description: from imagebank");
    header("Connection: close");
    echo $fileContents;
    }else{
    $numRows = mysql_num_rows($query);
    echo "File not found <br>";
    echo $numRows;
    echo " is the number of rows returned for id = ";
    echo $ID;
    ?>
    Hope that helps
    Phil

  • Report - Unable to display image stored on External server

    Hi
    I need to display image on report that is on different instance for that i had put a formula column (in report 10g) and for that coloum i made file format as image and read from file as Yes and giving it the URL of Image stored on different server . but at run time for PDF output i am getting error like REP-1295: Data format of column 'CF_1' is unsupported
    Please help me , Thx in advance.
    Ranga

    From the documentation:
    URL Reference
    1.Insert a dummy image in your template.
    2.In Microsoft Word's Format Picture dialog box select the Web tab. Enter the following syntax in the Alternative text region to reference the image URL:
    url:{'http://image location'}
    For example, enter: url:{'http://www.oracle.com/images/ora_log.gif'}
    Element Reference from XML File
    1.Insert a dummy image in your template.
    2.In Microsoft Word's Format Picture dialog box select the Web tab. Enter the following syntax in the Alternative text region to reference the image URL:
    url:{IMAGE_LOCATION}
    where IMAGE_LOCATION is an element from your XML file that holds the full URL to the image.
    You can also build a URL based on multiple elements at runtime. Just use the concat function to build the URL string. For example:
    url:{concat(SERVER,'/',IMAGE_DIR,'/',IMAGE_FILE)}
    where SERVER, IMAGE_DIR, and IMAGE_FILE are element names from your XML file that hold the values to construct the URL.
    This method can also be used with the OA_MEDIA reference as follows:
    url:{concat('${OA_MEDIA}','/',IMAGE_FILE)}
    Edited by: stevencallan on Feb 13, 2009 3:50 PM

  • Report - Not able to display image stored on External server or internet

    Hi
    I need to display image on report that is on different instance for that i had put a formula column (in report 10g) and for that coloum i made file format as image and read from file as Yes and giving it the URL of Image stored on different server . but at run time for PDF output i am getting error like REP-1295: Data format of column 'CF_1' is unsupported
    Please help me , Thx in advance.
    Ranga

    Hi,
    I've got the same problem.
    Did you find any solution?
    Thank you
    Davide

  • Pdf printing of an image stored in database?

    Hi,
    I am using pdf printing option, but stuck in a case where I need to retrieve a image from the database table stored as a blob content.
    Is it possible to create a report review of this sort?
    Is this even possible?
    Thanks..

    Hello,
    Yes, absolutely.
    Check out this blog post by Marc Sewtz on how to do it -
    http://marcsewtz.blogspot.com/2008/06/one-question-about-pdf-printing-feature.html
    Hope this helps,
    John.
    Blog: http://jes.blogs.shellprompt.net
    Work: http://www.apex-evangelists.com
    Author of Pro Application Express: http://tinyurl.com/3gu7cd
    REWARDS: Please remember to mark helpful or correct posts on the forum, not just for my answers but for everyone!

  • Problem in displaying images stored in Blob variable

    Hi all,
    I have a requirement where i need to retrieve the image stored in Blob variable in DB and display the image in JSP page.
    I have written the below code to achieve this, it works fine
    In JSP, I am calling a action in the <img tag
    <img src='downloadPhoto.page?method=getPhotoInBytes&accessoryModelPictures.id.accessoryNumber=${photo.id.accessoryNumber}/> In my controller class
    InputStream inputStream=accessoryPicturesLOB.getPicture().getBinaryStream();
    byte[] theBytes = new byte[inputStream.available()];
    inputStream.read(theBytes);
    response.setContentType("image/jpg");
    response.getOutputStream().write(theBytes);But the problem is, *if i right click on the image and select save picture as option i get a error saying "The system cannot find the specified file "*
    Can you please tell me what is wrong in my approach/code
    Is there any better approach to display image that is store in Blob variable ?
    Please help on this.
    Thanks in advance.

    You need at least to set the filename in the content disposition header.

  • Showing Image Stored In DataBase

    Hello Friends,
    I have images stored in MySQL database. In a blob field. In a desktop application i have used
    blob b=rs.getBlob("Picture");
    byte[] buf=b.getBytes((long)1,(int)b.length());
    ImageIcon imgIcon= new ImageIcon(buf);
    Image img=imgIcon.getImage();
    Graphics g=image.getGraphics();
    g.drawImage(img,0,0,320,240,image);
    the thing worked fine. But now i have to show images over web. I am not able to uderstand that how to show images. As i m unable to get Graphics from any of the component.
    Help Me,
    Its urgent,
    thanking u all
    Abhilash Jain

    The common method to include binary information (image, PDF, document, etc) is to Base64 encode the file and store the resulting character string in the XML. It would be up to the receiving system to handle the encoded information in the XML.

  • Cache of Displayed Images Stored in a BLOB

    I would like to know how I can cache the data that is an image stored as a blob? This is for when I refresh/revisit/branch to a page taht contains images sourced from a blob, such that it does not compel the browser to regenerate the blob image file data?

    Hi!
    We use jsp (for example ManagerPhoto.jsp), which is deployed to OC4J:
    Blob managerPhoto;
    response.reset();
    response.setHeader("Content-Disposition", "attachment; filename=manager_photo.jpg");
    response.setHeader("cache-control","public");
    ServletOutputStream outputStream = response.getOutputStream();
    outputStream.write(managerPhoto.getBytes(1, (int)managerPhoto.length()));
    out.clear();
    out = pageContext.pushBody();
    And HTML-code in the page to display an image:
    <img width=120 height=149 src=".../ManagerPhoto.jsp?p_orun_id=11">
    Regards,
    Al.

  • Displaying Images Stored on a Server In Flex

    My original idea for my app was to have live thumbnails of websites by screenshotting a html component in the app and saving these screenshots as jpgs which are applied as the source of the thumbnails. I now realise this is a bit too unstable as if the site doesn't load the images won't display. What I want to do instead is use the same idea but instead of the application writing to the application directory writing to a server where the images are stored so that it will overwrite these images.
    What I need to know is how to display server stored images in flex in either an image component or an array collection so they can be applied to a tilelist. The problem is I have zero experience at using server side data with flex. Can anyone point me in the direction to some examples/tutorials on how to display server stored data or more specifically images within a flex application or give me advice on this? Cheers.

    quick and easy way to do it would be with PHP.
    Make a script, scan a server folder and return the results in an XML format that can simply be fed into a datagrid/tilelist/whatever. To give you a few hints of what to look into.
    You'll need an initial HTTPService request fired off to the php script. The PHP script will then need to parse through the folder finding all the images, i'd recommend the glob() function in PHP to do this. eg:
    print "<images>";
    foreach (glob("directory/*.jpg") as $filename) {
        print "<screen><name>".$filename."</name><location>directory/".$filename."</location></screen>"
    print "</images>";
    then you'll need to handle the result event, simply feed each item into its respective place and ta daa.
    there are loads of examples around with this same methodology principle like this one:
    http://www.vipercreations.com/tutorials.php?t=28&page=1&c=Adobe%20Flex
    and i'm sure if you search around for 'flex php gallery' on google you'll probably even find a totally relevant example.

Maybe you are looking for