Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 445619FBB4B for ; Fri, 13 Jul 2007 15:45:57 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 57231-02 for ; Fri, 13 Jul 2007 15:45:48 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from web56609.mail.re3.yahoo.com (web56609.mail.re3.yahoo.com [66.196.97.53]) by postgresql.org (Postfix) with SMTP id A59279FB6F9 for ; Fri, 13 Jul 2007 15:45:53 -0300 (ADT) Received: (qmail 10038 invoked by uid 60001); 13 Jul 2007 18:45:28 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=3VOQaIztfalWGqB9ybcNa4nutPAcLXI2yl+L+ORpsUoznn549an1s0utCazkEBoH0LzGrzQwXksDqZIZfus805iQVkpWzy25ymEjoE5I+SManjU4Q+8LR9VQLIiOUrR4NNxrk93Pkfzu2MQaG18p9OcClL6OG6v9RExecMDBKB4=; X-YMail-OSG: tGhAAsAVM1nsSjoBR6QhpKlU.mS0519UWACZJn9DtaUzzwkiCMSpAKtfwRBmxe.JrfH6uEIqrwZwybwwQYjxrNawlAFC37AZ0LdOaQNDy26nsmNLwDBaT5tmv7cTmMIw4oHY6lVxoS5RvAI- Received: from [71.43.60.97] by web56609.mail.re3.yahoo.com via HTTP; Fri, 13 Jul 2007 11:45:25 PDT Date: Fri, 13 Jul 2007 11:45:25 -0700 (PDT) From: tomasz brymora Subject: BLOB, iBatis and PostgreSql To: pgsql-jdbc@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <531615.4242.qm@web56609.mail.re3.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/53 X-Sequence-Number: 17227 Greetings! I got lost trying to save and read an image file from a db. I get file upload taken care of where a servlet populates a bean with the image file and other info, but I can't get to be written to the db. What's the best way to procede, starting with the bean? Would this be appropriate: private MultipartFile imageBody; Given the following table: CREATE TABLE story_image ( image_name varying ( 30 ), image_description varying (50), image_body oid ); ... waht's the correct way to make the insert? I'm using iBatis for handling the jdbc part of the app. ... partial iBatis sqlMap: INSERT INTO images ( image_name, image_description, image_file ) VALUES ( #imageName#, #imageDescription#, lo_import( #imageBody# ) ); ... from what I gathered, pg uses a path to the image file for importing it, so should I store to a temp dir on the server and feed pg the path to it? Would the bean then require a String for the imageBody variable instead of the MultipartFile? Am I using the datatype for this operation (oid)? Before this I was able to store the image file in the db as 'bytea' but ran into problems trying to retrieve it: INFO: Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml] org.springframework.dao.DataIntegrityViolationExce ption: SqlMapClient operation; SQL []; --- The error occurred in com/persistance/sqlmaps_xml/imagesSqlMap.xml. --- The error occurred while applying a result map. --- Check the getImageResult. --- Check the result mapping for the 'imageBody' property. --- Cause: org.postgresql.util.PSQLException: Bad value for type int : \377 ... rest omitted... ... so I'll appreciate any feedback you might have.