From: Bill <bouma@cplane.com>
To: pgsql-interfaces@postgresql.org
Subject: JDBC driver writes binary data ONLY as Large Object
Date: Tue, 01 Aug 2000 12:37:03 -0700
Message-ID: <398726DF.D52AACA7@cplane.com> (raw)
The problem is that PreparedStatement.setBytes() only writes Large
Objects. It should do something like ResultSet.getBytes(), which
checks the column meta-data to see if the column holds an OID or
not, then do the right thing based on that.
Bill <bouma@cplane.com>
-------------------------------------------------
.../postgresql-7.0.2/src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java
/**
* Set a parameter to a Java array of bytes. The driver converts this
* to a SQL VARBINARY or LONGVARBINARY (depending on the argument's
* size relative to the driver's limits on VARBINARYs) when it sends
* it to the database.
*
* <p>Implementation note:
* <br>With org.postgresql, this creates a large object, and stores the
* objects oid in this column.
*
* @param parameterIndex the first parameter is 1...
* @param x the parameter value
* @exception SQLException if a database access error occurs
*/
public void setBytes(int parameterIndex, byte x[]) throws SQLException
{
LargeObjectManager lom = connection.getLargeObjectAPI();
int oid = lom.create();
LargeObject lob = lom.open(oid);
lob.write(x);
lob.close();
setInt(parameterIndex,oid);
}
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: bouma@cplane.com
Subject: Re: JDBC driver writes binary data ONLY as Large Object
In-Reply-To: <398726DF.D52AACA7@cplane.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox