<% response.s" name="description">

pint multiple images from blob database

pint multiple images from blob database

How to display multiple images using blob from mysql database. The program code is as below:

<TABLE cellpadding="15" border="1" style="background-color: #ffffcc;"> <% response.setContentType("image/gif"); OutputStream o = response.getOutputStream(); while (res.next()) { %> <TR>

    <TD><%
image = res.getBlob(1);

imgData = image.getBytes(1,(int)image.length());

o.write(imgData);

%> <TD><%=res.getInt(2)%>

</TR>
<%   }    %>
<%
// close all the connections.
o.flush();
o.close();
res.close();
statement.close();
connection.close();

} catch (Exception ex) {

View Answers

April 7, 2011 at 12:14 PM

1)images:

<%@ page import="java.sql.*,java.io.*,java.util.*" %> 
<HTML>
 <table border="1">
 <tr><th>ID</th><th>Image</th></tr>
   <%
  try{      
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
    Statement stmt=con.createStatement();
    String strQuery = "select * from data";
    ResultSet rs = stmt.executeQuery(strQuery);
    while(rs.next()){
       %>
      <tr>
      <td><%=rs.getInt("id")%></td>
      <td>
      <img src="image.jsp?imgid=<%=rs.getInt(1)%>" width="100" height="100">
</a></td>
      </tr>
      <%
    }
    rs.close();
    con.close();
    stmt.close();
  }
  catch(Exception e)
  {
    e.getMessage();
  }
  %>
 </table>
</HTML>

2)image.jsp:

<%@ page import="java.sql.*,java.io.*,java.util.*" %> 
<%
  int id =  Integer.parseInt(request.getParameter("imgid"));
  try{      
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");      
    Statement st=con.createStatement();
    String strQuery = "select image from data where id="+id;
    ResultSet rs = st.executeQuery(strQuery);

    String imgLen="";
    if(rs.next()){
      imgLen = rs.getString(1);
       }  
    rs = st.executeQuery(strQuery);
    if(rs.next()){
      int len = imgLen.length();
      byte [] rb = new byte[len];
      InputStream readImg = rs.getBinaryStream(1);
      int index=readImg.read(rb, 0, len);  
      st.close();
      response.reset();
      response.getOutputStream().write(rb,0,len); 
      response.getOutputStream().flush();        
    }
  }
  catch (Exception e){
    e.printStackTrace();
  }
%>









Related Tutorials/Questions & Answers:
pint multiple images from blob database
pint multiple images from blob database  How to display multiple images using blob from mysql database. The program code is as below: <TABLE cellpadding="15" border="1" style="background-color: #ffffcc;"> <
display multiple images from postgres database in jframe
display multiple images from postgres database in jframe  i just want to display multiple images on jframe by firing a query on postgres database
Advertisements
How to retrieve blob image from database in JSP?
How to retrieve blob image from database in JSP?  Hello, JSP is used... the blog image from database. How to retrieve blob image from database in JSP?   Hi, Please check the tutorial Retrieve image from database using
Blob images - JSP-Servlet
Blob images  Hi sir how can i retrieve blob images from database using jsp from mysql  Hi Friend, Please visit the following link: http://www.roseindia.net/jsp/retrieve-image.shtml Hope that it will be helpful
Spring 3.2 MVC insert and retrieve blob from the database
In this section, you will learn about inserting and retrieving blob from the database
How to store multiple images in folder and images path in database at a time using jsp?
How to store multiple images in folder and images path in database at a time using jsp?  I wanna browse multiple images in one form and store them in one folder and their path into datrabase
how to display multiple images on browser
how to display multiple images on browser  i want to display multiple images on brower including string values from sql database using jsp
how to display multiple images on browser
how to display multiple images on browser  i want to display multiple images on brower including string values from sql database using jsp
how to retrieve images from database to jsp?
how to retrieve images from database to jsp?  Hi sir,i want to stores images along with the name and price with database and retrieve it on jsp.and... urgent.   1)images: <%@ page import="java.sql.*,java.io.*,java.util.
Retrieve multiple data from database into Table.....
Retrieve multiple data from database into Table.....   hi........... I want to Retrieve multiple data from database into Table but i am not able... database i have attributes pH, phosphate, ....... month, year......... so its
Download images from Database in JSP
Download images from Database in JSP  ... developed a web application to download images from database in JSP. Two files... the image from database. All images will show as hyperlink image.  2
how to store and retrieve images int and from the database using php
how to store and retrieve images int and from the database using php  please anyone can help me in storing the images and retrieve it back from the Mysql database using php
Retrieving value from multiple table in database
Retrieving value from multiple table in database  Hi fnds, I want to maintain the financial database of 20 users for 1 year and update the details... FROM ( SELECT * FROM month1 UNION ALL SELECT * FROM month2 UNION ALL
how insert multiple images in mysql database with use of struts 1.3.8 or java method, with single bean,or using array
how insert multiple images in mysql database with use of struts 1.3.8 or java... ,with struts 1.3.8 and i want to insert multiple images in mysql database ,with use of struts 1.3.8 ,or with the help of Array methods ,like google multiple
Show multiple identical rows into JTable from database
Show multiple identical rows into JTable from database In this tutorial, you will learn how to display the multiple rows from database to JTable. Here is an example that search the data from the database and show multiple identical
how to retrieve text and images from mysql database and show on html page using jsp servlet
how to retrieve text and images from mysql database and show on html page using...="javax.sql.*" %> <%@ page import="java.io.*" %> <% Blob image = null; byte... Complaints: Complaint Timing User Name Complaint Details Complaint Images
Selecting particular data from multiple tables at database and perfoming calculations
Selecting particular data from multiple tables at database and perfoming calculations  Hi fnds, I want to maintain the financial database of 20 users for 1 year and update the details in jsp page.. so i have decided
How to display multiple images in jsp
How to display multiple images in jsp  <%@ page import="java.io.... = stmt.executeQuery("select IMAGE from student_profile "); //ResultSet rs1=stmt.executeQuery("select count(id) from student_profile"); bl=new ArrayList<Blob>
Retrieving images from the oracle database using jsp and create that rretrieved image as hyperlink
Retrieving images from the oracle database using jsp and create that rretrieved image as hyperlink  I want to insert images into oracle database.I want to retrieve images using jsp and I want to display on the browser.The
Deleting Blob Data from Database table using servlet
Deleting Blob Data from Database table using servlet In this section, we will discuss about how to insert a blob data into a database table. A Blob stores a binary large object in the database table's row. Blob object
insert images into a Mysql database
insert images into a Mysql database  How can I insert images into a Mysql database
display multiple image file or pdf file in multiple column of a row from server or database
display multiple image file or pdf file in multiple column of a row from server or database  hello sir I have uploaded the file to the server and I... in a particular format i.e I have to display more than one files in multiple columns
TO connect multiple database
TO connect multiple database  How to connect several database from a single application in java depending upon the user input it will connect to that database
Display Multiple Images in jscrollpane using Java Jpanel
Display Multiple Images in jscrollpane using Java Jpanel  Browse and Display multiple images in vertical view of java jscrollpane using jpanel
how to store multiple values from drop down in database where i am using java struts 1.3
how to store multiple values from drop down in database where i am using java... where i have to select multiple keyskills. but it is taking only one valuee.. i... is displaying.. i need code in java so that it takes multiple values
Display Blob(Image) from Mysql table using JSP
Display Blob(Image) from Mysql table using JSP In this section, we will display blob data(image) from Mysql database table using JSP code. A Blob stores a binary large object in the database table's row. Blob object contains
how to scroll multiple images using on Click in Android
how to scroll multiple images using on Click in Android  I am new... there is requirement like multiple image scrolling dynamically. But unfortunately i am unable to scroll multiple images. But i am able to scroll single image. plz let me know
How to show multiple identicle rows from database on clicking search button to jtable
How to show multiple identicle rows from database on clicking search button...); } } }); } }   Here is a code that search the data from the database and show multiple identical rows from database on clicking search button
How to show multiple identicle rows from database on clicking search button to jtable
How to show multiple identicle rows from database on clicking search button...); } } }); } }   Here is a code that search the data from the database and show multiple identical rows from database on clicking search button
How to show multiple identicle rows from database on clicking search button to jtable
How to show multiple identicle rows from database on clicking search button...); } } }); } }   Here is a code that search the data from the database and show multiple identical rows from database on clicking search button
Data from multiple ResultSets?
Data from multiple ResultSets?  hello, How can I get data from multiple ResultSets?   Hi,ADS_TO_REPLACE_1 You can iterate the ResultSet separately and get the required data. Thanks
get and display blob from mysql on jsf
get and display blob from mysql on jsf  i want to get blob from mysql, and display on jsf page. your examples with jsp. i dont find an example with jsf. plese help me about this. thanks..   Have a look at the following
inserting multiple file formats into database
inserting multiple file formats into database  hi i want to insert multiple file format like .pdf.doc.zip into mysql database using jsp
get images from web service
get images from web service  How to get images from web services in iPhone application?   to get images from web service xml? For Uploading NSString *encodedString=[self encode:(const uint8_t*)_secretData.bytes
How to save excel sheet into mysql database using blob or clob
How to save excel sheet into mysql database using blob or clob  Hi... me the steps to do this, i am able to connect to the database, from there i don't know to go further, which one should i use BLOB or CLOB ? I have tried using
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... to upload the multiple images in struts Total images storing folder in project...;COLLEGE INFORMATION :</legend> <pre> Gallery Images: <input type
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... to upload the multiple images in struts Total images storing folder in project...;COLLEGE INFORMATION :</legend> <pre> Gallery Images: <input type
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... to upload the multiple images in struts Total images storing folder in project...;COLLEGE INFORMATION :</legend> <pre> Gallery Images: <input type
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... to upload the multiple images in struts Total images storing folder in project...;COLLEGE INFORMATION :</legend> <pre> Gallery Images: <input type
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... to upload the multiple images in struts Total images storing folder in project...;COLLEGE INFORMATION :</legend> <pre> Gallery Images: <input type
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... to upload the multiple images in struts Total images storing folder in project...;COLLEGE INFORMATION :</legend> <pre> Gallery Images: <input type
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... to upload the multiple images in struts Total images storing folder in project...;COLLEGE INFORMATION :</legend> <pre> Gallery Images: <input type
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... to upload the multiple images in struts Total images storing folder in project...;COLLEGE INFORMATION :</legend> <pre> Gallery Images: <input type
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... to upload the multiple images in struts Total images storing folder in project...;COLLEGE INFORMATION :</legend> <pre> Gallery Images: <input type
ModuleNotFoundError: No module named 'Pint'
ModuleNotFoundError: No module named 'Pint'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Pint' How to remove the ModuleNotFoundError: No module named 'Pint' error
mysql select from multiple tables
mysql select from multiple tables   how can i select the date field from multiple tables in mysql?   "UNION" can be used to select data from multiple tables in my sql... for example (SELECT * from name where `name
redirect to multiple links from servlet
redirect to multiple links from servlet  hello , In my servlet page , i'm using response.redirect("www.somewebsiteaddress.com"); after it shows... want redirect to multiple links simultaneously. anyone help me out
retrieve multiple columns values from multiple csv files in java
retrieve multiple columns values from multiple csv files in java  ...)///// here VendorID is corresponding to file1.csv i want to retrive data from these two files and store in oracle database as: VendorID,Name,Address and plz
Displaying images - JDBC
Displaying images  How to display multiple images on a single jsp from MySql database
Displaying images - JDBC
Displaying images  How to display multiple images on a single jsp from MySql database

Ads