Re: Java Studio Creator Fix/Hack

Поиск
Список
Период
Сортировка
От Kris Jurka
Тема Re: Java Studio Creator Fix/Hack
Дата
Msg-id Pine.BSO.4.56.0412102043320.31603@leary.csoft.net
обсуждение исходный текст
Ответ на Java Studio Creator Fix/Hack  (Pucky Loucks <ploucks@h2st.com>)
Ответы Re: Java Studio Creator Fix/Hack
Список pgsql-jdbc

On Fri, 10 Dec 2004, Pucky Loucks wrote:

> Hi everyone, I noticed at TODO for getMetaData() on the 8.0 and figured
> I'd give this task a try.  I now am able to use Java Studio Creator
> with Postgresql 7.4.6.
>
> public ResultSetMetaData getMetaData() throws SQLException
> { ResultSet rs = null;
> checkClosed();
> rs = getResultSet();
>
> if(rs == null)
> {
> // the following code hack has not been fully tested, therefor use at
> your own risk.
> /// by Pucky Loucks of How2share Technologies (creators of PiXPO)
>
> StatementResultHandler handler = new StatementResultHandler();
>
> connection.getQueryExecutor().execute(preparedQuery,
> preparedParameters,
> handler,
> 0,
> 0,
> QueryExecutor.QUERY_ONESHOT);
> rs = handler.getResults().getResultSet();
> }
>
> return rs.getMetaData();
> }
> ===================END OF CODE HACK=====


This patch doesn't really work.  It assumes that the PreparedStatement
doesn't have side effects and that all parameters have been set.

Consider:

PreparedStatement pst = con.prepareStatement("UPDATE tab SET x=x+1");
pst.getMetaData();
pst.execute();

Now all of a sudden x = x+2.  Actually your patch will throw a
NullPointerException, but that's a simple code issue.

Consider:

PreparedStatement pst = con.prepareStatement("SELECT * FROM t WHERE x=?");
pst.getMetaData();

Fails with: org.postgresql.util.PSQLException: No value specified for
parameter 1.

The planned way to implement this feature is with the V3 protocol issuing
Parse/Bind/Describe/ClosePortal without ever executing it.

Kris Jurka

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Kris Jurka
Дата:
Сообщение: Re: 8.0.0beta4: "copy" and "client_encoding"
Следующее
От: Kris Jurka
Дата:
Сообщение: Re: PostgreSQL + SSL - sun.security.validator.ValidatorException