• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

BLOB, iBatis & PostgreSql 8.1

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:


Given the following table:


... waht's the correct way to make the insert?
I'm using iBatis for handling the jdbc part of the app.

... partial iBatis sqlMap:

... 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.
 
I have gone to look for myself. If I should return before I get back, keep me here with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic