Re: ParameterMetaData getPrecision() always zero? - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: ParameterMetaData getPrecision() always zero?
Date
Msg-id alpine.BSO.2.00.1001291617290.31378@leary.csoft.net
Whole thread Raw
In response to ParameterMetaData getPrecision() always zero?  (Simon Temple <simon.temple@amalto.com>)
List pgsql-jdbc

On Thu, 28 Jan 2010, Simon Temple wrote:

>     ParameterMetaData m = stat.getParameterMetaData(  );
>     int colWidth = m.getPrecision( parameterIndex );
>
> For varchar columns I would expect to get the maximum column width.  So 8
> for a varchar(8).
>
> I always get zero as a result.
>

This is the best the JDBC driver can do.  When preparing a statement, the
server only returns the datatypes, not additional details about the size.
This is because the parameters do not always match up with a table column.
Consider "WHERE replace(col, 'a', 'bb') = ?"  you won't be able to tell
the parameter size from that.

Kris Jurka

pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: LIKE and ESCAPING in JDBC Select Statement
Next
From: Kris Jurka
Date:
Subject: Re: Object types and ResultSets (java.sql.Struct)