Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet image in database

Have Programming Question? Ask it here!
 
 
 


renuga devi
image in database
1 Answer(s)      3 years and 6 months ago
Posted in : JSP-Servlet


how to set image in database and retrieve it using servlet(java)in msaccess


Advertisement
View Answers

February 1, 2011 at 11:55 AM


Hi Friend,

Try the following code:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;

public class ImageServlet extends HttpServlet { 
    public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        try{
    InputStream sImage;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
           Connection con = DriverManager.getConnection("jdbc:odbc:student");
File imgfile = new File("C:/rose.jpg");
      FileInputStream fin = new FileInputStream(imgfile);
      PreparedStatement pre = con.prepareStatement("insert into user(name,address,image) values(?,?,?)");
      pre.setString(1,"A");
      pre.setString(2,"Delhi");
      pre.setBinaryStream(3,fin,(int)imgfile.length());
      pre.executeUpdate();
      System.out.println("Inserting Successfully!");
      pre.close();
      Statement st=con.createStatement();
      ResultSet rs=st.executeQuery("select image from user where id=1");
if(rs.next()){
byte[] bytearray = new byte[1048576];
int size=0;
sImage = rs.getBinaryStream(1);
response.reset();
response.setContentType("image/jpeg");
while((size=sImage.read(bytearray))!= -1 ){
response.getOutputStream().write(bytearray,0,size);
}
}
rs.close();
st.close();
con.close();
}
catch(Exception ex){
out.println("error :"+ex);
}
        }
}

For the above code, we have created a table

user(id,name,address,image)
id(AutoNumber)
name(text)
address(text)
image(OLE Object)

Thanks



Related Tutorials/Questions & Answers:
image in database
image in database  how to set image in database and retrieve it using servlet(java)in msaccess
inserting image into database
inserting image into database  how to insert image into database using struts frame work and spring JDBC
Advertisements
Fetching image from database
Fetching image from database  I have uploaded image path and image name in database so, now how can i display that image using JSP or HTML page... in database is:E:\1003\54175\20110407121554 image name i have stored
image retrive into DataBase - JDBC
the image into DataBase. Thanks & Regards, VijayaBabu.M  Hi, Retrieving image from database is easy task. JDBC provides all the necessary API and function to retrieve the image from database. You retrieve image from database
How to store image into database
How to store image into database  Hi, all I want to store image into database using Java. Can anyone help me that how can i store image into database using Java. Thanks in advance.   hi friend, To store image
image store in database - JDBC
; Inserting Image in Database Table http://www.roseindia.net/jdbc/jdbc-mysql/insert... to store image into database. Check at http://www.roseindia.net/servlets/insert...image store in database  Dear Deepak Sir, If I want to store image
upload image to database
upload image to database  i am try to upload image to MySql database using netbeans. when jsp execute it return no error. but also data does inserted in database. i am using blob datatype and preopared statement
Resize image stored in database
Resize image stored in database  hi, Can any one please send code for how to resize image stored in database in blob datatype in jsp, i want to resize it to 140(w)*160(h) please help me
Insert image in database
Insert image in database  Want a jsp-struts program in which the imageFile is in the form of getter and setter and inserted in the database as a Blob using . and then download the image and show on next jsp pg. No use
Image name,image path into database and image into folder using jsp
Image name,image path into database and image into folder using jsp  How to insert image path and image name into oracle database and image into folder using jsp
Unable to store the image into database
); }   Hi, Please check the thread How to Insert image into database...Unable to store the image into database  Hello, I have created below... of image. I have debug the JSP program and found that HTML form pass only image
How to store an image in database
How to store an image in database  Hi........... How to store an image in postgresql using a query. I mean tell me the way to store an image using datatype. I am using the datatype bytea but tell me how to insert the image
How to retrieve image from database
How to retrieve image from database  hi........ How to retrieve image from database when it is stored. I have stored image in postgresql and want... but it retrieves as a string and not complete image can u tel me the conversion
store and retrive image from the database
store and retrive image from the database  please provide me... to store and retreive images from sql database using sql commands -how to store and retreive images from sql database using asp.net/c# thanks in advance
image upload and stored in database - JSP-Servlet
image upload and stored in database  How can i upload a image and store that image in a database
image upload and stored in database - JSP-Servlet
image upload and stored in database  How can i upload a image and store that image in a database
Save profile and image to mysql database, and view the image in another jsp page
Save profile and image to mysql database, and view the image in another jsp page  Pls. need help in saving the profile info with the image in mysql database.. some basic code pls in jsp... thanks in advance
inserting an path of an image in database - JDBC
inserting an path of an image in database  hello kindly help related... an image using web cam.... and when the image is saved in a project at the same time its full path should be inserted in the database(MS Sql 2000).. I m able
Problem in uploading image to to mysql database
be save in the database. and the image will also save in the desired folder. i...Problem in uploading image to to mysql database  Hi, need some help here, i have a program where a user can input name, city and upload image. when
Problem in uploading image to to mysql database
be save in the database. and the image will also save in the desired folder. i...Problem in uploading image to to mysql database  Hi, need some help here, i have a program where a user can input name, city and upload image. when
Retrieving the Image from a database Table
Retrieving the Image from a database Table Consider a case where we want... come. For this it is necessary that there must be his/her image in the database... to retrieve the image from the database table. You can do it very easily after
store & retrive the image from oracle database
store & retrive the image from oracle database  how can i store the image path in tha database & fetch that image from oracle database
Inserting Image in Database Table
Inserting Image in Database Table   ... helps the user to insert an image in the MySQL database table. To insert an image, you need to establish a connection with MySQL database. Lets' take
retriving image from database - JSP-Servlet
retriving image from database  how to retrive image from mysql database by using servlet programming  Hi Friend, Please visit the following link: http://www.roseindia.net/servlets/retreiveimage.shtml Thanks
Image upload in mysql database using jsp servlet
Image upload in mysql database using jsp servlet  Hello, I need code to insert image in mysql database, I have seen the code which is already in your portal but it is not inserting image into database it save in the folder
Uploading a Profile with image[file] into a sql database
Uploading a Profile with image[file] into a sql database  I need to upload a file along with the some text into a database ......[ Similar to http... , but upload file to database ] ... Pls help
how to insert the physical path of an image in database - JDBC
how to insert the physical path of an image in database  hello I m working in a project where we have to capture an image using web cam. when the image is captured it is saved in folder in a project folder and at the same time
how to store and retrieve image from database
how to store and retrieve image from database  how to store and retrieve images into database(oracle) and how to retrive images from database using jsp   Here is a jsp code that insert and retrieve image from mysql
store and retrive image from database - JDBC
store and retrive image from database  how to store and retrive an image in database using java?  Hi friend, Code for store image...()); } } } For retrieve image from database visit to : http
how to save uploaded image in database using javascript
how to save uploaded image in database using javascript  Please can you tell me how to store uploaded image in database using java I'll use...; Now i want to store it on database... Please help me Thanks in Advance
Insert  Image into Database Using Servlet
Insert  Image into Database Using Servlet   ... of inserting image into database table using Servlet. This type of program is useful... photograph of the user. If the image is stored in the database you can easily
Insert Image into Database Using Servlet
Insert  Image into Database Using Servlet   ... image into database table using Servlet. This type of program is useful in social... photograph of the user. If the image is stored in the database you can easily
image displaying from database with some other information
image displaying from database with some other information  hi, in the following section of code when i am not displaying the image it is working properly but when i tried to display the image nothing is displayed on browser
how to store image upload path to mssql database
help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit button, the id in the database do increment by 1 however under the image column
how to store image upload path to mssql database
help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit button, the id in the database do increment by 1 however under the image column
how to store image upload path to mssql database
help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit button, the id in the database do increment by 1 however under the image column
how to store image upload path to mssql database
help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit button, the id in the database do increment by 1 however under the image column
How to store user name,city,state,image path into database and image into folder using jsp
How to store user name,city,state,image path into database and image into folder using jsp  How to store user name,city,state,image path into database and image into folder using jsp
how to store image in folder and stored image path in mysql database using JSP
how to store image in folder and stored image path in mysql database using JSP  how to store image in folder and stored image path in mysql database using JSP
how we retrieve image from database
how we retrieve image from database  my code is:- $search=$_POST...;lt;/table&amp;amp;gt;"; mysql_close($con);   PHP retrieve image from mysql database: <?php mysql_connect("localhost","username","password
Insert image from user using and save in database
to upload a image from user and trying to save into oracle9i database...){e.printStackTrace();} } %> 3)For oracle database, use BLOB datatype for image.   dear sir or madam, i wont to How to Store Image Into The Database
insert name city and upload image in database using mysql and jsp
insert name city and upload image in database using mysql and jsp   insert name city and upload image in database using mysql and jsp
retrive image from database using jsp without stream
retrive image from database using jsp without stream  How to retrive image from database using jsp without stream like (inputStream
insert and retrive image from sql server database in jsp
insert and retrive image from sql server database in jsp  what is the code to insert and retrive an image from sql server database in jsp
How to insert image in sql database from user using servlet
How to insert image in sql database from user using servlet  pls tell me accept image from user and insert image in sql server 2005 database using servlet and jsp
Upload Image to Database through Servlet - JSP-Servlet
Upload Image to Database through Servlet  Hello, I make a application from where I upload the Image from local disk then store in DB.Before storing the Image in DB I want to check this program. I include the commons
how to display or retrive an image in jsp whose path is stored in oracle database
how to display or retrive an image in jsp whose path is stored in oracle database  how to display or retrive an image in jsp whose path is stored in oracle database and the image is stored in my pictures folder
image upload and stored in database - JSP-Servlet
image upload and stored in database  How can i upload a image and store that image in a database  Hi Friend, Try the following code: 1)page.jsp: Display file upload form to the user UPLOAD
<img src=""> using retrieve image from database using jsp
using retrieve image from database using jsp  how to <img src="" > tag using retrieve image from database and display in jsp
Adding image to database through jsp or HTML page ,while adding only image should show.
Adding image to database through jsp or HTML page ,while adding only image should show.   Adding image to database through jsp or HTML page,while adding only image should show. After that i need view that uploaded image from
Advertisements
 

 

 

DMCA.com