Blob

Blob

View Answers

August 31, 2009 at 4:59 PM

Hi Friend,

Use the following code:

<%@page import="java.io.*"%>
<%@page import="java.sql.*"%>
<%
String connectionURL = "jdbc:mysql://localhost:3306/test";;
Connection con=null;
Statement stmt = null;
ResultSet rs = null;
Blob image = null;
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root";);
stmt = con.createStatement();
rs = stmt.executeQuery("select image from image where image_id =1");
if (rs.next()) {
image = rs.getBlob(1);
}
File f=new File("C:\\newImage.jpg");
FileOutputStream fos=new FileOutputStream(f);
InputStream in = image.getBinaryStream();
int length = (int) image.length();
int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
while ((length = in.read(buffer)) != -1) {
fos.write(buffer, 0, length);
}
out.println("Image is saved into the file.");
in.close();
fos.close();
} catch (Exception e){}
finally {
try {
rs.close();
stmt.close();
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
%>

Hope that it will be helpful for you.
Thanks









Related Tutorials/Questions & Answers:
get Blob
get Blob   how i can display a Blob in XHTML (i developpe with hbernate
Blob column
Blob column  Hi all... How to store an excel file in Blob column? I m using oracle 11 g database
Advertisements
Oracle BLOB
Oracle BLOB  Can anyone send me the code for inserting an image or audio into the oracle database using BLOB datatype. Plz...it's useful for my project
BLOB - SQL
as BLOB in the mysql database and retrieve the image and display it in the web...){} Blob image = null; Statement stmt = null; ResultSet rs...("Display Blob Example"); out.println("image not found for given id
ModuleNotFoundError: No module named 'blob'
ModuleNotFoundError: No module named 'blob'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'blob' How to remove the ModuleNotFoundError: No module named 'blob' error
Blob update in hibernate
Blob update in hibernate  Hi , I wanted to upload a blob into mysql database using hibernate. Could you please help me . Thanks in advance, Satchidanand Mohanty
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
MySQL BLOB
MySQL BLOB This example illustrates how to create the BLOB type field... field blob type.  ADS_TO_REPLACE_1 Query  ..._increment, `image` blob, PRIMARY KEY(`id`) );  
upload SQL BLOB and CLOB - JDBC
upload SQL BLOB and CLOB  Please explain upload SQL BLOB and CLOB
Blob - JSP-Servlet
Blob  Hi Friend, Thank you very much for all the answers. I need the code for reading a BLOB field(image) from the database and write the same to a file(jpg file) using JSP. Thank you in advance  Hi Friend, Use
ModuleNotFoundError: No module named 'with-cloud-blob'
ModuleNotFoundError: No module named 'with-cloud-blob'  Hi, My... named 'with-cloud-blob' How to remove the ModuleNotFoundError: No module named 'with-cloud-blob' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'with-cloud-blob'
ModuleNotFoundError: No module named 'with-cloud-blob'  Hi, My... named 'with-cloud-blob' How to remove the ModuleNotFoundError: No module named 'with-cloud-blob' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'blob_app'
ModuleNotFoundError: No module named 'blob_app'  Hi, My Python... 'blob_app' How to remove the ModuleNotFoundError: No module named 'blob_app... to install padas library. You can install blob_app python with following
ModuleNotFoundError: No module named 'blob-utils'
ModuleNotFoundError: No module named 'blob-utils'  Hi, My Python... 'blob-utils' How to remove the ModuleNotFoundError: No module named 'blob... have to install padas library. You can install blob-utils python
Convert BLOB to PDF and save it to a location
Convert BLOB to PDF and save it to a location  I have a requirement to convert blob(stored in a DB table) back to .pdf in the UI(for the users to download). i could achieve this for single blob to file conversion(with a prompt
using Blob in jdbc - JDBC
using Blob in jdbc  Hi, I got an Exception when i was trying to insert one image into oracle 10g database the exception is Exception in thread "main" java.sql.SQLException: ORA-01460: unimplemented or un reasonable
ModuleNotFoundError: No module named 'PyUpdater-Azure-Blob-Plugin'
ModuleNotFoundError: No module named 'PyUpdater-Azure-Blob-Plugin'  ...: No module named 'PyUpdater-Azure-Blob-Plugin' How to remove the ModuleNotFoundError: No module named 'PyUpdater-Azure-Blob-Plugin' error? Thanks
ModuleNotFoundError: No module named 'scrapy-feedexporter-azure-blob'
ModuleNotFoundError: No module named 'scrapy-feedexporter-azure-blob' ...: No module named 'scrapy-feedexporter-azure-blob' How to remove the ModuleNotFoundError: No module named 'scrapy-feedexporter-azure-blob' error
ModuleNotFoundError: No module named 'scrapy-feedexporter-azure-blob'
ModuleNotFoundError: No module named 'scrapy-feedexporter-azure-blob' ...: No module named 'scrapy-feedexporter-azure-blob' How to remove the ModuleNotFoundError: No module named 'scrapy-feedexporter-azure-blob' error
ModuleNotFoundError: No module named 'azure-storage-blob'
ModuleNotFoundError: No module named 'azure-storage-blob'  Hi, My... named 'azure-storage-blob' How to remove the ModuleNotFoundError: No module named 'azure-storage-blob' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'js.javascript_canvas_to_blob'
ModuleNotFoundError: No module named 'js.javascript_canvas_to_blob'  ...: No module named 'js.javascript_canvas_to_blob' How to remove the ModuleNotFoundError: No module named 'js.javascript_canvas_to_blob' error
Get Blob
Get Blob       Blob is known as 'binary large object', is a collection of binary data stored... is the video tutorial of "How to get blob image from MySQL Database?":ADS
Insert Mysql Blob data
Insert Mysql Blob data   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 contains a logical pointer
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
how to retrieve blob data - JSP-Servlet
how to retrieve blob data  How to retrieve the BLOB table having single row single column in Database containing memory information using JSP as a table format?   Hi friend, I am sending you a link. I hope
How to retrieve blob image from database in JSP?
How to retrieve blob image from database in JSP?  Hello, JSP is used for dynamic web applications. In my dynamic web application I want to display the blog image from database. How to retrieve blob image from database in JSP
how to expose blob in restful web service client java
how to expose blob in restful web service client java   how to expose blob in restful webservice clientside and how to convert the blob into a file,please help me
how to expose blob in restful web service client java
how to expose blob in restful web service client java   how to expose blob in restful webservice clientside and how to convert the blob into a file,please help me
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
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;"> <
Difference between Normal Insert and BLOB insert
Difference between Normal Insert and BLOB insert  I have sql database...\Pictures\Sample Pictures\Tulips.jpg', SINGLE_BLOB) AS BLOB) Here is the code... normal insert image.. I dont want to use AS BLOB in insert statement   
how to expose blob in restful web service client java rest template
how to expose blob in restful web service client java rest template  how to expose blob in restful web service client java rest template
ModuleNotFoundError: No module named 'core-module-remote-blob-host-app'
ModuleNotFoundError: No module named 'core-module-remote-blob-host-app' ...: ModuleNotFoundError: No module named 'core-module-remote-blob-host-app' How to remove the ModuleNotFoundError: No module named 'core-module-remote-blob-host-app'
ModuleNotFoundError: No module named 'core-module-advanced-blob-host-app'
ModuleNotFoundError: No module named 'core-module-advanced-blob-host-app' ...: ModuleNotFoundError: No module named 'core-module-advanced-blob-host-app' How to remove the ModuleNotFoundError: No module named 'core-module-advanced-blob-host-app
ModuleNotFoundError: No module named 'core-module-blob-host-app'
ModuleNotFoundError: No module named 'core-module-blob-host-app'  Hi...: No module named 'core-module-blob-host-app' How to remove the ModuleNotFoundError: No module named 'core-module-blob-host-app' error? Thanks  
ModuleNotFoundError: No module named 'core-module-remote-blob-host-app'
ModuleNotFoundError: No module named 'core-module-remote-blob-host-app' ...: ModuleNotFoundError: No module named 'core-module-remote-blob-host-app' How to remove the ModuleNotFoundError: No module named 'core-module-remote-blob-host-app'
org.apache.jackrabbit - oak-blob-plugins version 1.8.6 Maven dependency. How to use oak-blob-plugins version 1.8.6 in pom.xml?
org.apache.jackrabbit  - Version 1.8.6 of oak-blob-plugins Maven dependency? How to use  org.apache.jackrabbit  - Version 1.8.6 of oak-blob-plugins in pom.xml? How to use oak-blob-plugins version 1.8.6 in pom.xml? Learn
org.apache.jackrabbit - oak-blob version 1.10.4 Maven dependency. How to use oak-blob version 1.10.4 in pom.xml?
org.apache.jackrabbit  - Version 1.10.4 of oak-blob Maven dependency? How to use  org.apache.jackrabbit  - Version 1.10.4 of oak-blob in pom.xml? How to use oak-blob version 1.10.4 in pom.xml? Learn to use this dependency
org.apache.jackrabbit - oak-blob version 1.6.19 Maven dependency. How to use oak-blob version 1.6.19 in pom.xml?
org.apache.jackrabbit  - Version 1.6.19 of oak-blob Maven dependency? How to use  org.apache.jackrabbit  - Version 1.6.19 of oak-blob in pom.xml? How to use oak-blob version 1.6.19 in pom.xml? Learn to use this dependency
org.apache.jackrabbit - oak-blob version 1.10.4 Maven dependency. How to use oak-blob version 1.10.4 in pom.xml?
org.apache.jackrabbit  - Version 1.10.4 of oak-blob Maven dependency? How to use  org.apache.jackrabbit  - Version 1.10.4 of oak-blob in pom.xml? How to use oak-blob version 1.10.4 in pom.xml? Learn to use this dependency
org.apache.jackrabbit - oak-blob version 1.7.11 Maven dependency. How to use oak-blob version 1.7.11 in pom.xml?
org.apache.jackrabbit  - Version 1.7.11 of oak-blob Maven dependency? How to use  org.apache.jackrabbit  - Version 1.7.11 of oak-blob in pom.xml? How to use oak-blob version 1.7.11 in pom.xml? Learn to use this dependency
org.apache.jackrabbit - oak-blob version 1.2.31 Maven dependency. How to use oak-blob version 1.2.31 in pom.xml?
org.apache.jackrabbit  - Version 1.2.31 of oak-blob Maven dependency? How to use  org.apache.jackrabbit  - Version 1.2.31 of oak-blob in pom.xml? How to use oak-blob version 1.2.31 in pom.xml? Learn to use this dependency
org.apache.jackrabbit - oak-blob version 1.2.15 Maven dependency. How to use oak-blob version 1.2.15 in pom.xml?
org.apache.jackrabbit  - Version 1.2.15 of oak-blob Maven dependency? How to use  org.apache.jackrabbit  - Version 1.2.15 of oak-blob in pom.xml? How to use oak-blob version 1.2.15 in pom.xml? Learn to use this dependency
Maven Repository/Dependency: org.apache.jackrabbit | oak-blob
Maven Repository/Dependency of Group ID org.apache.jackrabbit and Artifact ID oak-blob. Latest version of org.apache.jackrabbit:oak-blob dependencies. # Version Release Date 1
Servlet Example To Display Mysql Blob Data
Servlet Example To Display Mysql Blob Data    ... type BLOB. The BLOB type stores/retreives large binary objects such as PDF files, video clips, JPEG/GIF pictures, and Microsoft word documents. A BLOB
store the image in the oracle using blob and get it back - JDBC
store the image in the oracle using blob and get it back  hi i am... { PreparedStatement ps = conn.prepareStatement("INSERT INTO IMAGES VALUES (?, empty_blob... by // InputStream is = rs.getBinaryStream(1); Blob blob = rs.getBlob(1
Maven Repository/Dependency: org.apache.jackrabbit | oak-blob-plugins
Maven Repository/Dependency of Group ID org.apache.jackrabbit and Artifact ID oak-blob-plugins. Latest version of org.apache.jackrabbit:oak-blob-plugins dependencies. # Version Release Date
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 All, I am new to java and i need to upload excel sheet to mysql, please suggest... know to go further, which one should i use BLOB or CLOB ? I have tried using
Insert Blob(Image) in Mysql table using JSP
Insert Blob(Image) in Mysql table using JSP In this Section, we will insert blob data(image) in Mysql database table using JSP code. A Blob stores a binary large object in the database table's row. Blob object contains a logical
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

Ads