Hi,
I found this post in a forum. What do you think about it? :)
Christophe
----------------------------------------------------------------------------
----
I have used JDBC extensively with pg 7.2.4, but I have not used the bytea
type to send data to/from a java application.
I found the most relevant data in the 7.4 documentation, and it says 7.2 is
the first version that supports bytea through the JDBC driver.
Version 7.2 was the first release of the JDBC driver that supports the bytea
data type. The introduction of this functionality in 7.2 has introduced a
change in behavior as compared to previous releases. Since 7.2, the methods
getBytes(), setBytes(), getBinaryStream (), and setBinaryStream () operate on
the bytea data type. In 7.1 and earlier, these methods operated on the oid
data type associated with Large Objects. It is possible to revert the driver
back to the old 7.1 behavior by setting the property compatible on the
Connection object to the value 7.1.
To use the bytea data type you should simply use the getBytes(), setBytes(),
getBinaryStream (), or setBinaryStream () methods.
and perhaps exactly what you may be looking for
To insert an image, you would use:
File file = new File("myimage.g if");
FileInputStream fis = new FileInputStream (file);
PreparedStateme nt ps = conn.prepareSta tement("INSERT INTO images VALUES (?,
?)");
ps.setString(1, file.getName()) ;
ps.setBinaryStr eam(2, fis, file.length());
ps.executeUpdat e();
ps.close();
fis.close();
Here, setBinaryStream () transfers a set number of bytes from a stream into
the column of type bytea. This also could have been done using the
setBytes() method if the contents of the image was already in a byte[].
Retrieving an image is even easier. (We use PreparedStateme nt here, but the
Statement class can equally be used.)
PreparedStateme nt ps = con.prepareStat ement("SELECT img FROM images WHERE
imgname = ?");
ps.setString(1, "myimage.gi f");
ResultSet rs = ps.executeQuery ();
if (rs != null) {
while (rs.next()) {
byte[] imgBytes = rs.getBytes(1);
// use the data in some way here
}
rs.close();
}
ps.close();
Here the binary data was retrieved as an byte[]. You could have used a
InputStream object instead. 2 2298
My questions are ... ^^
Why insert files in a data base? And is this powerful?
Greeting
Christophe
"CM" <no*****@ulg.ac .be> wrote in message news:<c7******* ***@ikaria.beln et.be>... My questions are ... ^^ Why insert files in a data base? And is this powerful?
Greeting Christophe
Security perhaps. Also, adding attributes to the files and indexing
them. For instance, annotating the people in a picture and when the
picture was taken. Then later being able to find any pictures with a
certain person in a time range. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Brandon J. Van Every |
last post by:
What's better about Ruby than Python? I'm sure there's something. What is
it?
This is not a troll. I'm language shopping and I want people's answers. I
don't know beans about Ruby or have any preconceived ideas about it. I have
noticed, however, that every programmer I talk to who's aware of Python is
also talking about Ruby. So it seems that Ruby has the potential to compete
with and displace Python. I'm curious on what basis it...
|
by: perseus |
last post by:
I think that everyone who told me that my question is irrelevant,
in particular Mr. David White,
is being absolutely ridiculous. Obviously, most of you up here
behave like the owners of the C++ language. A C++ interface
installation IS ABOUT THE C++ LANGUAGE! The language
does not possess the ability to handle even simple file directory
manipulation.
Those wise people that created it did not take care of it. So, BOOST
is a portable...
|
by: Sarah Tanembaum |
last post by:
Beside its an opensource and supported by community, what's the fundamental
differences between PostgreSQL and those high-price commercial database (and
some are bloated such as Oracle) from software giant such as Microsoft SQL
Server, Oracle, and Sybase?
Is PostgreSQL reliable enough to be used for high-end commercial
application? Thanks
|
by: Ka |
last post by:
Hi, all
I use Redhat8.0, and I complie a program with wine in this box,
my wine version is wine-20020605-2 by Redhat. and after install wine,
I just locate the library in /usr/lib/wine
lrwxrwxrwx 1 root root 17 Jul 29 12:10 libgdi32.dll.so ->
wine/gdi32.dll.so
lrwxrwxrwx 1 root root 20 Jul 29 12:10
libkernel32.dll.so -> wine/kernel32.dll.so
|
by: Keith K |
last post by:
Having developed with VB since 1992, I am now VERY
interested in C#. I've written several applications with
C# and I do enjoy the language.
What C# Needs:
There are a few things that I do believe MSFT should do to
improve C#, however.
I know that in the "Whidbey" release of VS.NET currently
| |
by: Nadav |
last post by:
Hi,
I am tring to pass messages between threads, using the good old C++ I would call the GetMessage/PostThreadMessage APIs, Now, I am using C# and i can't find any equivalenty for these calls, any Idea how to communicate between threads and access the threads message queue will be appriciated...
--
Nadav
http://www.ddevel.com
|
by: Jason Huang |
last post by:
Hi,
Would someone explain the following coding more detail for me? What's the
( ) for?
CurrentText = (TextBox)e.Item.Cells.Controls;
Thanks.
Jason
|
by: Veeru |
last post by:
Hi,
Can anyone tell me the difference between heap memory and stack stack
both physically and fundamentally. It would be a real favour.
Regards,
Veeru
|
by: Tee |
last post by:
Hi,
Just curious what is clickone? Is it the same as Installshield?
Been follow the following instructions and it seems to create an
installation exe for me which is good but how come it doesn't include the
..net framework as part of the installation exe too? if i was giving this exe
to a friend or a client i am sure they can't run the application after the
installed. If the clickone is the same as installshield how do i go about
to...
|
by: process |
last post by:
I have heard some criticism about Python, that it is not fully object-
oriented.
What is not an object in Python?
Why isn't len implemented as a str.len and list.len method instead of
a len(list) function?
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |