473,516 Members | 3,248 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to retrieve a blob field from MySQL table?

10 New Member
I have a longblob field in a table that stores pics and other files. I am developing a Java application that needs to retrieve the files from the database and view them. I know that the longblob fields are binary data. Could you please provide me with some sample code that will at least retrieve the file from the database and save it on the user's hard disk?

If there is a way to store a file as blob, then there should be a way to retrieve it!

Thanks
Mar 30 '09 #1
1 4789
Atli
5,058 Recognized Expert Expert
Hi.

From MySQL's point of view, fetching BLOB data is done in exactly the same way as all the other data types... with a SELECT query:
Expand|Select|Wrap|Line Numbers
  1. SELECT `blobField` FROM `myTable`
The result of that will then be piped through whatever connection you used to execute the query.

I'm not much of a Java coder myself, so I can't really comment on how Java would handle the return data, but I would imagine it is either returned as a string or a byte array.

I suggest you ask in the Java forum for details, or look through the documentation for your MySQL connector class.
(As I understand it, Java has excellent documentation)
Apr 8 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
7070
by: John | last post by:
I have over 5000 thumbnail pictures of size 5kb each. I would like to able to load all 5000 pictures and view 50 per page using mysql_data_seek(). I would like to know what are the advantages and disadvantages of using a MySQL blob field rather than reading the images directly from the file? How does one insert an image into a blob field?...
0
1697
by: Andy Jackman | last post by:
Hi, I'm new to mySql. I've got a table with an integer field defined like this: l_start_wait int(9) not null I inserted a value into the table using mysql command line client with: Insert into tbl_wait_list values(12345678); When I use mysql_fetch_row() to retrieve the column values I am surprised to see that mysql_fetch_lengths()...
0
2298
by: Mark Fisher | last post by:
I cannot seem to store binary data as a BLOB. I used the following to create a table capable of holding a BLOB: CREATE TABLE blob_table ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, binary_stuff BLOB, PRIMARY KEY (id) );
0
1513
by: qhe | last post by:
Dear All: I'm using MyODBC 3.51.06 and MySQL 4.0.18. My table has a mediumblob field, but I can't update/insert data larger than 64K. The test application is created by VC6 appwizard, here is the test code: m_pSet->GetODBCFieldInfo(2, fieldinfo); n = fieldinfo.m_nPrecision;
0
2251
by: mcstayinskool | last post by:
I'm trying to dump a bugzilla installation to a file, then restore it to a different database name (so as to test my db backup system). I use mysqldump to dump it to a file: # mysqldump -u root -p<passwd> (misc. options) bugs > bugs.sql Then try to restore it to an empty DB, "foobar" with this command # mysql -u root -p<passwd> foobar <...
7
11438
by: sime | last post by:
Hi, I have a blob field in a mysql database table. I want to copy a blob from one record to another. I am having trouble transferring the data via a php variable. Maybe I need to addslashes or convert to Hex or something. I've tried a few things but can't quite get it. Here is simplified code. mysql_select_db($dbname, $connection);
3
4702
by: hamvil79 | last post by:
I'm implementig a java web application using MySQL as database. The main function of the application is basically to redistribuite documents. Those documents (PDF, DOC with an average size around 2Mb) are stored in BLOB column. The amount of documents for the first year should not exceed 5/6 Giga, but I cannot make prevision for the next...
2
8991
by: pmz | last post by:
Dear Group, I'm connecting in C# with remote (BSD) MySQL server with ODBC Driver, and I'm trying to find the best sollution in such problem: As I've read on MySQL manual, they have suggested table design including the BLOB-Fieldtype size in UInt64, where they've stored, while inserting, the size of inserted BLOB data. But in the matter of...
1
4793
by: yoes | last post by:
Dear all, I am very new in MySQL, I am working on image database project for my research and I have problem how to convert blob field into float in MySQL so that I can calculate the blob field with the MATH operation. Does any one how to do it ???? Thank you very much indeed , for your help.
0
7273
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7405
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7547
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3252
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1620
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.