Subject Patch to fix blob handling
Author lhoriman
I'm using blobs with hibernate (actually ejb3 in jboss). My code is
entirely DB agnostic except for one small problem... the JayBird
driver won't accept any implementation of java.sql.Blob except it's
own. You can't use java.sql.Blob without relying on firebird-specific
code.

This patch changes AbstractPreparedStatement.setBlob() so that instead
of throwing an exception, it converts the foreign Blob into a FBBlob.

Thanks,
Jeff Schnitzer


Index: src/main/org/firebirdsql/jdbc/AbstractPreparedStatement.java
===================================================================
RCS file:
/cvsroot/firebird/client-java/src/main/org/firebir
dsql/jdbc/AbstractPreparedStatement.java,v
retrieving revision 1.18.2.1
diff -u -r1.18.2.1 AbstractPreparedStatement.java
--- src/main/org/firebirdsql/jdbc/AbstractPreparedStatement.java 24
Oct 2004 16:07:47 -0000 1.18.2.1
+++ src/main/org/firebirdsql/jdbc/AbstractPreparedStatement.java 19
May 2005 08:15:55 -0000
@@ -725,9 +725,9 @@
*/
public void setBlob (int parameterIndex, Blob blob) throws
SQLException {
if (!(blob instanceof FBBlob)) {
- throw new FBSQLException(
- "You must use FBBlobs with Firebird.",
- FBSQLException.SQL_STATE_INVALID_PARAM_TYPE);
+ FBBlob fbb = (FBBlob)c.createBlob();
+ fbb.copyStream(blob.getBinaryStream(), (int)blob.length());
+ blob = fbb;
}
getField(parameterIndex).setBlob((FBBlob) blob);
isParamSet[parameterIndex - 1] = true;