Subject Re: [Firebird-Java] Re: getParameterMetaData
Author Nickolay Samofatov
Hello, Roman,

>> I implemented method getParameterMetaData method from JDBC 3.
>> This method was also implemented in InterClient since version 1.0.
>> Are there any objections if I commit my implementation to CVS HEAD ?

My implementation works, but I have a couple questions about
ResultSetMetaData (as it should have the simular logic, but it is
different). I really cannot understand logic of this piece of code.

Simple background:

1. sqllen is documented to be max length of buffer in bytes,
but it actually returns physical database-side buffer size for column
in its character set.

2. sqlsubtype is charset ID for CHAR/VARCHAR column.

Do derive character length of buffer you need to divide
sqllen by char width of charset of this column (you can look up this

But Jaybird code is obviously broken regarding this point as it tries
to use API as documented, not taking into account its real behavior,
look here for example:

case Types.CHAR:
case Types.VARCHAR:

if (fieldInfo == null) {
String encoding = getIscEncoding();
int length = getXsqlvar(column).sqllen;
return length / FBConnectionHelper.getIscEncodingSize(encoding);
// This returns 20 for 60-char column if
// UNICODE_FSS connection charset is used and
// column charset is single-byte
} else
return fieldInfo.characterLength;

Roman, what do you think ?

Nickolay Samofatov mailto:skidder@...