I'm quite confused now.  I've seen this patch before but not with reference
to "Connection.java in the jdbc2 directory", only Field.java.  I have tried
modifiying Field.java but don't think I have done it correctly - could you
please explain how to apply the patch mentioned (or even better point me to
a working driver).

My code at the moment allows me to insert an images but not retrieve it.
For example the method doUpload (below) below produces this output:

image1 size: 1475
image2 size: 1


----

        public void doUpload( RunData data,Context context )
                throws Exception
        {
                PpImage entry = new PpImage();
                FileItem fileItem = data.getParameters().getFileItem("theFile");

                byte[] image1 = fileItem.get();
                System.out.println("image1 size: " + image1.length);

                data.getParameters().setProperties(entry);
                entry.setImageBinary(image1);
                entry.save();

                Criteria c = new Criteria();

                // get this primary key of the image just inserted
                c.add(PpImagePeer.ASSET_VERSION_ID, entry.getAssetVersionId());
                Vector v = PpImagePeer.doSelect(c);
                PpImage img = (PpImage)v.elementAt(0);

                String fileName = entry.getAssetVersionId() + ".jpg";
                String filePath = TurbineServlet.getRealPath("images/temp");

                byte[] image2 = img.getImageBinary();
                System.out.println("image2 size: " + image2.length);

                // write the image to disk so we can take a look at it
                FileOutputStream fis = new FileOutputStream(filePath + "/" + fileName);
                fis.write(image2);
                fis.flush();
                fis.close();
        }

---

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 21 September 2001 16:48
To: [EMAIL PROTECTED]
Subject: Re: inserting images to postgresql


Nick Pomfret wrote:
>
> Does anyone know of a postgresql driver which works with oid fields in
> postgresql?
>
> When trying to insert an image (or any other oid field) I  get a 'Bad
> conversion: java.lang.NumberFormatException'.
>
> The notes in http://jakarta.apache.org/turbine/howto/postgres-howto.html
> describe a patch which may fix the problem, having never applied a patch
it
> didn't make much sense to me.  I tried decompiling Field.class and making
> the changes but this didn't work.
>
> I'm working with village-1.5.2 and postgresql driver that comes downloaded
> with tdk2.1
>
> Thanks in advance.
>
> Nick

        You have to change Connection.java in the jdbc2 directory..
        Try this patch file:

+diff -r1.1 Connection.java
+286c286
 <     "int4","oid",
 ---
 >     "int4",
-158a159
+297a298
 >     "oid",
-172c173
+311c312
 <     Types.INTEGER,Types.INTEGER,
 ---
 >     Types.INTEGER,
-183a185
+322a324
 >     Types.VARBINARY,


Atte.
Jerome
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

--
- Au 4 coins d'Paris qu'on va l'retrouver �parpill� par petits bouts
fa�on puzzle...
Moi quand on m'en fait trop j'correctionne plus, j'dynamite...
j'disperse... et j'ventile...

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to