Re: SQLException: Invalid precision value. Cannot be less than zero - Mailing list pgsql-jdbc

From Nebojsa Vasiljevic
Subject Re: SQLException: Invalid precision value. Cannot be less than zero
Date
Msg-id 006a01c50f5e$35f57b70$ad00a8c0@mediacenter.org.yu
Whole thread Raw
In response to SQLException: Invalid precision value. Cannot be less than zero  ("Nebojsa Vasiljevic" <nebojsa@sw4i.com>)
List pgsql-jdbc

> That's right we *can't change the spec*.
>
> But hold on guys, I can put a try catch block for this and prevent
> the SQLException from being thrown in the implementation,
> wherever it is being called in from *other classes*.
> And hence we can go on.
>
> But yes I can't change the spec class from doing that.
> It's(return -1 for variable length data) is used by various JDBC drivers
> that way.
>
> Does that help ?

Method

javax.sql.rowset.RowSetMetaDataImpl.setColumnDisplaySize()

throws exception after it is called from:

com.sun.rowset.CachedRowSetImpl.initMetaData(CachedRowSetImpl.java:679)

If you catch exception in CachedRowSetImpl.java, you have to decide what
value
to put in columnDisplaySize property. Possible answer is:

If columnDisplaySize, precision or scale property of ResultSetMetaData is -1
then appropriate property of RowSetMetaDataImpl will be 0.

(and you don't need try/catcher to do that)

If various JDBC drivers use -1, this may be reasonable solution.


Nebojsa


pgsql-jdbc by date:

Previous
From: "Nebojsa Vasiljevic"
Date:
Subject: Re: SQLException: Invalid precision value. Cannot be less than zero
Next
From: "Kenneth Hutchinson"
Date:
Subject: Re: Crystal Reports / PostgreSQL