Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2007

Tip: Looking for answers? Try searching our database.

java

Thread view: 
ramana praharaju - 20 Jun 2007 10:36 GMT
how to write a jdbc code that should store image object in the database
Martin Gregorie - 20 Jun 2007 12:54 GMT
> how to write a jdbc code that should store image object in the database

If you're storing it as a BLOB, use PreparedStatement.setBinaryObject(),
passing a class derived from InputStream, something like a
ByteArrayInputStream, or FileInputStream, as the parameter.

Signature

martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

Lee Fesperman - 22 Jun 2007 08:29 GMT
> > how to write a jdbc code that should store image object in the database
> >
> If you're storing it as a BLOB, use PreparedStatement.setBinaryObject(),
> passing a class derived from InputStream, something like a
> ByteArrayInputStream, or FileInputStream, as the parameter.

ITYM, PreparedStatement.setBinaryStream().

Alternatively, you can use an array of bytes and
PreparedStatement.setBytes(). Or, you can use
PreparedStatement.setBlob() if your DBMS provides an implementation of
java.sql.Blob on the client side.

--
Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com)
==============================================================
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS  (http://www.firstsql.com)
Roedy Green - 22 Jun 2007 11:21 GMT
On Wed, 20 Jun 2007 09:36:51 -0000, ramana praharaju
<ramana.8@gmail.com> wrote, quoted or indirectly quoted someone who
said :

>how to write a jdbc code that should store image object in the database
You first of all have to convert it to an platform independent format
such as JPG or PNG.  See http://mindprod.com/jgloss/jpgencoder.html
http://mindprod.com/jgloss/pngencoder.html

now you have an array of bytes.  This can be stored in a database as a
BLOB type.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.