Re: create BLOB question - Mailing list pgsql-jdbc
From | Barry Lind |
---|---|
Subject | Re: create BLOB question |
Date | |
Msg-id | 3E4AB308.2020104@xythos.com Whole thread Raw |
In response to | create BLOB question (Jeremiah Jahn <jeremiah@goodinassociates.com>) |
List | pgsql-jdbc |
Jeremiah, From the jdbc documentation: PostgreSQL provides two distinct ways to store binary data. Binary data can be stored in a table using PostgreSQL's binary data type bytea, or by using the Large Object feature which stores the binary data in a separate table in a special format, and refers to that table by storing a value of type OID in your table. In order to determine which method is appropriate you need to understand the limitations of each method. The bytea data type is not well suited for storing very large amounts of binary data. While a column of type bytea can hold up to 1 GB of binary data, it would require a huge amount of memory (RAM) to process such a large value. The Large Object method for storing binary data is better suited to storing very large values, but it has its own limitations. Specifically deleting a row that contains a Large Object does not delete the Large Object. Deleting the Large Object is a separate operation that needs to be performed. Large Objects also have some security issues since anyone connected to the database can view and/or modify any Large Object, even if they don't have permissions to view/update the row containing the Large Object. 7.2 is the first release of the JDBC Driver that supports the bytea data type. The introduction of this functionality in 7.2 has introduced a change in behavior as compared to previous releases. In 7.2 the methods getBytes(), setBytes(), getBinaryStream(), and setBinaryStream() operate on the bytea data type. In 7.1 these methods operated on the OID data type associated with Large Objects. It is possible to revert the driver back to the old 7.1 behavior by setting the compatible property on the Connection to a value of 7.1 To use the bytea data type you should simply use the getBytes(), setBytes(), getBinaryStream(), or setBinaryStream() methods. To use the Large Object functionality you can use either the LargeObject API provided by the PostgreSQL JDBC Driver, or by using the getBLOB() and setBLOB() methods. Some of the formatting was lost in the cut-n-paste of this from the doc, but in summary if you add '?compatible=7.1' to your connection URL you will get the old behavior. thanks, --Barry Jeremiah Jahn wrote: > does some9one out there know how to create a new oid from scratch. > setBytes on 7.2 worked fine for me, but with the change to 7.3 I can't > seem to get a new oid number. I want to avoid any postgres specific > stuff. Correct me if I'm wrong, but It seems to me that the setBytes > goes with the bytea stuff and the BLOB stuff goes with the oid stuff. I > just can't seem to figure out how to insert a new oid/BLOB. > > any help would be great, > thanx > -jj-
pgsql-jdbc by date: