Обсуждение: Testing JDBC Prepared Statements

Поиск
Список
Период
Сортировка

Testing JDBC Prepared Statements

От
Daniel Migowski
Дата:
Hello dear developers,

We are beginning to have a bunch of SQL statements in an evolving
application, and are facing the problem, that every rename of a database
attribute (refactor early and often ;), breaks some of our statements.

To find what we broke, we are currently looking for postgresql to
prepare all the statements, without actually executing them, and to see,
which fail.

As far as I understand, the JDBC API wraps the internal implementation
of PreparedStatements from the user (and with PostgreSQL, there is a
distinction between client/server side prepared statements, anyway).

Is it possible with the PostgreSQL JDBC driver (leaving the JDBC API
space is allowed) to serverside prepare a statement without executing it?

With best regards,
Daniel Migowski

Re: Testing JDBC Prepared Statements

От
Kris Jurka
Дата:

On Wed, 14 May 2008, Daniel Migowski wrote:

> Is it possible with the PostgreSQL JDBC driver (leaving the JDBC API
> space is allowed) to serverside prepare a statement without executing
> it?

PreparedStatement.getParameterMetaData will prepare a statement without
executing it.

Kris Jurka

Re: Testing JDBC Prepared Statements

От
Daniel Migowski
Дата:
Kris Jurka schrieb: <blockquote cite="mid:Pine.BSO.4.64.0805141301410.24785@leary.csoft.net" type="cite">On Wed, 14
May2008, Daniel Migowski wrote: <br /><blockquote type="cite">Is it possible with the PostgreSQL JDBC driver (leaving
theJDBC API space is allowed) to serverside prepare a statement without executing it? <br /></blockquote>
PreparedStatement.getParameterMetaDatawill prepare a statement without executing it. <br /></blockquote> Thank you. I
alsoalready helped me with something like statement.executeQuery("PREPARY test AS "+myQueryToTest), but your variant
doesapropriate query parsing, which seem better.<br /><br /> With best regards,<br /> Daniel Migowski<br /><br /><br
/><divclass="moz-signature">-- <br /><pre> |¯¯|¯¯|    <b>IKOffice GmbH             Daniel Migowski</b>|  |  |/|
                  Mail: <a href="mailto:dmigowski@ikoffice.de">dmigowski@ikoffice.de</a>|  | // |  Nordstr. 10
    Tel.: 0441 21 98 89 52|  | \\ |  26135 Oldenburg           Fax.: 0441 21 98 89 55|__|__|\|  <a
href="http://www.ikoffice.de">http://www.ikoffice.de</a>   Mob.: 0176 22 31 20 76</pre></div>