Hey Chad,
I have not tested if this works for a VARCHAR column, but I have used
getColumnDisplaySize (int column) on the
ResultSetMetaData of a given ResultSet with succes, hope this is to some help.
Martin
Chad Loder <cloder@acm.org> on 12-05-2000 07:26:57
Please respond to instantDB@enhydra.org
To: instantdb@enhydra.org
cc:
Subject: InstantDB: Apparent bug in CHAR(255) reported length
Hello. When I execute the following statement to create a database:
CREATE TABLE pslogdat (
log_id_high INTEGER NOT NULL ,
log_id_low INTEGER NOT NULL ,
log_seq BYTE NOT NULL ,
log_subt INTEGER NOT NULL ,
log_subseq BYTE NOT NULL ,
log_data VARCHAR(255),
primary key (log_id_high, log_id_low, log_seq, log_subseq))
Then I use the following code to catalog the column length:
DatabaseMetaData dmd = conn.getMetaData();
ResultSet drs = dmd.getColumns("", null, "pslogdat", "log_data");
if (drs != null)
{
if (drs.next())
{
String colName = drs.getString(4);
int maxData = drs.getInt(7);
System.out.println("Length of " + colName + " is " + maxData);
}
}
The output I get is:
"Length of log_data is 65536".
The JDBC documentation states that the COLUMN_SIZE column (7)
is the maximum number of characters when the column in question
is a char or date type. Shouldn't the database be returning 255
here? Is this a bug, and if so, is there a workaround?
Thanks,
Chad (wishing I had the source code so I could debug this)
-----------------------------------------------------------------------------
To unsubscribe from this mailing list, send email to majordomo@enhydra.org
with the text "unsubscribe instantdb" in the body of the email.
If you have other questions regarding this mailing list, send email to
the list admin at owner-instantdb@enhydra.org.
-----------------------------------------------------------------------------
To unsubscribe from this mailing list, send email to majordomo@enhydra.org
with the text "unsubscribe instantdb" in the body of the email.
If you have other questions regarding this mailing list, send email to
the list admin at owner-instantdb@enhydra.org.
|