Results 1 to 4 of 4
  1. #1
    redmaverick is offline Member
    Join Date
    Oct 2009
    Posts
    6
    Rep Power
    0

    Default How to display Images from MS access using JSP

    I tried and succeeded in pulling out the info from the ms access database tables. But I am not able to pull out the images. They are in the text form.

    Is there any way to overcome this


    this is my code:
    Java Code:
    <html>
    <body>
    
    
    <%@ page import="java.sql.*,java.awt.Image" %>
    <%
    Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn=null;
    conn = DriverManager.getConnection("jdbc:odbc:simpledb", "", "");
    out.println ("Database Connected.");
    Statement s = conn.createStatement();
    ResultSet r =
    s.executeQuery(
    "SELECT * " +
    "FROM bookprice");
    
    while(r.next()) {
    
    out.println(
    r.getString("title") + " " +
    r.getString("price")+r.getString("Image"));
    }
    
    %>
    
    
    </body>
    </html>

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default

    I very much doubt (but admit I could be wrong) that you can store images in a text field. Do you mean you've stored the URL of the image there?

  3. #3
    redmaverick is offline Member
    Join Date
    Oct 2009
    Posts
    6
    Rep Power
    0

    Default

    yeah, that's my problem. It is not possible to store image in text. I need to replace r.getString("Image"); with something appropriate like r.getImage/getBlob("Image"); but it is of no use.......I was wondering if anybody knows how to store and retrieve OLE Image from MS access

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default

    You want to use the appropriate datatype, which would be Ole Object (looking at some access documentation). Then, presumably, use setBinaryStream to put it into the db, and getBinaryStream to get it out. I prefer to use streams, before anyone mentions get and setBlob.

    Now, I have no idea if Access will work with this, but the "proper" dbs do.

Similar Threads

  1. Default Access (package access) confusion
    By gauravrajbehl in forum New To Java
    Replies: 1
    Last Post: 11-18-2009, 10:48 AM
  2. display images
    By prof.deedee in forum AWT / Swing
    Replies: 10
    Last Post: 11-12-2009, 09:08 PM
  3. Dynamic display of images
    By gixerino in forum NetBeans
    Replies: 7
    Last Post: 01-15-2009, 02:55 PM
  4. Replies: 8
    Last Post: 12-29-2008, 07:12 AM
  5. Replies: 0
    Last Post: 03-25-2008, 12:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •