Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2009
    Posts
    3

    Unanswered: Issue using LargeObject & LargeObjectManager classes

    All,

    I am using the following 2 classes when I extract a data of type OID from the postgres d/b

    LargeObject
    LargeObjectManager

    the code is something like this

    LargeObjectManager lobj = ((org.postgresql.PGConnection)conn).getLargeObject API();
    LargeObject obj = lobj.open(oid, LargeObjectManager.READ);
    // Read the data
    byte buf[] = new byte[obj.size()];
    obj.read(buf, 0, obj.size());
    obj.close();

    Howevere we may start using a different d/b altogether in the future.
    Is there any way I can make this code generic
    i.e. use a class from Spring framework to handle data of type OID

    Eventually the ApplicationContext.xml or a .properties file will
    hold details of the d/b (driver class etc) that is used, so I need a way to handle
    blob / OID datatype using Spring framework and not the database specific API.

    Can someone point me in the right direction.

    regards,

  2. #2
    Join Date
    Sep 2009
    Posts
    3

    Issue using LargeObject & LargeObjectManager classes

    forgot to mention that - the 2 classes are from postgres.jar

    org.postgresql.largeobject.LargeObject;
    org.postgresql.largeobject.LargeObjectManager;

  3. #3
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    How big will your binaries be?
    How do you access those binaries?

    The Large Objects API only makes sense if the get really big and if you only need to access them partially.

    In any other case (size of the blobs <= 1GB and you always access them completely) bytea is the far better choice.

    From within JDBC you can access them via the getBlob() or getBinaryStream() APIs in a generic way.

  4. #4
    Join Date
    Sep 2009
    Posts
    3

    Issue using LargeObject & LargeObjectManager classes

    Thanks,

    getBlob() method does what I wanted, I no longer explicitly use the Postgres.jar in my project

  5. #5
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Just be aware that getBlob() and setBlob() are not implemented correctly in all drivers.
    Using getBinaryStream() and setBinaryStream() is much more portable.

    You'll need to check that with the other (potential) DBMS/drivers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •