-
Notifications
You must be signed in to change notification settings - Fork 22
JDBC Extension Guide
drotiro edited this page Aug 23, 2010
·
3 revisions
The PostPic JDBC extension complements the PostgreSQL driver for easier managing of ‘image’ objects.
It adds a Java class — PGImage
— to represent images and an utility class.
First of all, we need to tell the PostgreSQL driver to map ‘image’ fields to PGImage instances.
Newer versions of the driver support ‘autoregistration’: they do this mapping automatically by reading a properties file bundled in the extension.
Anyway, the utility class PostPic
has methods to check whether the registration has been done and to do it manually:
import postpic.PostPic
...
PostPic pp = new PostPic(conn);
if(!pp.isRegistered()) {
pp.registerManual()
}
Whenever your ResultSet
contains an image field, you can obtain the corresponding PGImage this way:
PGImage pi = (PGImage) rSet.getObject("column_name");
To get the corresponding java.awt.Image
you can do:
Image img = pi.getImage();