Slashdot Mirror


Dealing with BLOBs in Postgres?

Greyfox asks: "I've got a question and it's been bugging me for a while. I'm trying to do some database programming with Java and PostgresSQL. I've got an array of bytes I'd like to store in the database and I can't quite figure out how to do it. I've tried the method suggested in their old documentation (Which involves doing some JDBC thing with a FileInputStream) and some esoteric BLOB thing involving ResultSet.setBytes() and a more esoteric BLOB thing involving their LargeObjectManager and when I'm at my most successful I get error messages back griping about unexpected EOFs from the connection manager or somesuch. The documentation, example code and web searches have all been profoundly unhelpful. Am I going about this the right way and if I am, what am I missing?"

4 of 16 comments (clear)

  1. Funny by JMZero · · Score: 2, Informative

    Large object documentation

    Or you can use bytea or TEXT like I do.

    -Dave

    --
    Let's not stir that bag of worms...
  2. Possible Solution by Slipped_Disk · · Score: 2, Informative

    One possible solution I came up with was to UUEncode the data, then store it in a text field.

    I never actually implemented this, but it should be fairly easy to do (either outside the DB or using a Postgres user-defined function.

    The existing BLOB support is documented briefly Here, but quite honestly it... well sucks.

    --
    /~mikeg
  3. PostgreSQL JDBC docs by shrike · · Score: 2, Informative

    You should have a look at the PostgreSQL JDBC documentation, which can be found at http://jdbc.postgresql.org. While you're at it, also search for BYTEA in the PGSQL JDBC mailingslist.

  4. Re:What's going on with Slashdot? by platypus · · Score: 2, Informative

    Ok, I'm a bit late, but anyway:

    You are so right.

    Esp. when you go to google and type in:

    postgres 7.1 blob jdbc

    you get the following link on the first page of search results:

    http://www.postgresql.org/idocs/index.php?jdbc-l o. html