use of com.teradata.jaqy.connection.JaqyResultSetMetaData in project jaqy by Teradata.
the class ResultSetUtils method getDisplayWidth.
public static int getDisplayWidth(JaqyResultSet rs, int column) throws SQLException {
JaqyResultSetMetaData meta = rs.getMetaData();
// some JDBC drivers (notably SQLite JDBC does not have
// the correct display size settings. So here we force
// the correct calculation.
int displaySize = meta.getColumnDisplaySize(column);
int type = meta.getColumnType(column);
int computeSize = displaySize;
switch(type) {
case Types.INTEGER:
{
computeSize = 10;
if (meta.isSigned(column))
++computeSize;
break;
}
case Types.REAL:
{
int precision = meta.getPrecision(column);
if (precision <= 7) {
// we are dealing a 4-byte real
computeSize = precision + 2;
if (meta.isSigned(column))
++computeSize;
} else if (precision <= 53) {
computeSize = precision + 2;
if (meta.isSigned(column))
++computeSize;
}
break;
}
case Types.BINARY:
case Types.VARBINARY:
{
int size = meta.getColumnDisplaySize(column);
computeSize = size * 2;
break;
}
default:
{
computeSize = displaySize;
break;
}
}
return Math.min(computeSize, displaySize);
}
Aggregations