Thread: Support for named parameters in the PostgreSQL JDBC driver
Dear PGSQL-JDBC Team,<br /><br /> Could you please let me know if the support for "<i>Named Parameters</i>" in the JDBCdriver is slated for some future release?<br /><br /> Currently with the 8.1.4 JDBC driver, the call to <i>CallableStatement.setString(String,String) </i>fails and the <a href="http://developer.postgresql.org/cvsweb.cgi/%7Echeckout%7E/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Statement.java?rev=1.4;content-type=text%2Fplain;hideattic=0">code </a>isthrowing the following exception - <br /><br /> "Caused by: org.postgresql.util.PSQLException: Method org.postgresql.jdbc3.Jdbc3CallableStatement.setString(String,String)is not yet implemented."<br /><br /> Thanks<br /> Ravi<br/><br /><br /><br /><br /><br />
Ravi,
The backend does not support named parameters, so I doubt this will be coming anytime soon.
Dave
On 16-Nov-06, at 1:29 AM, Ravi Periasamy wrote:
Dear PGSQL-JDBC Team,
Could you please let me know if the support for "Named Parameters" in the JDBC driver is slated for some future release?
Currently with the 8.1.4 JDBC driver, the call to CallableStatement.setString(String, String) fails and the code is throwing the following exception -
"Caused by: org.postgresql.util.PSQLException: Method org.postgresql.jdbc3.Jdbc3CallableStatement.setString(String,String) is not yet implemented."
Thanks
Ravi
On Thu, 16 Nov 2006, Ravi Periasamy wrote: > Dear PGSQL-JDBC Team, > > Could you please let me know if the support for "Named Parameters" in the > JDBC driver is slated for some future release? > Just recently I noticed an overlooked patch that implements this: http://archives.postgresql.org/pgsql-jdbc/2006-07/msg00011.php The suggested patch isn't quite right, but its approach can work in many cases. If functions are not overloaded then a simple lookup of parameter names by the function name would work. If the function is overloaded we might be able to use the parameter type given by setXXX to try and determine what function we're actually calling, but it's probably better to just error out in that case. Kris Jurka
The patch looks promising, however my gut reaction to this is that until it's supported by the protocol this will break more often than it will work. On top of that named parameters are not part of the SQL spec. Dave On 16-Nov-06, at 12:52 PM, Kris Jurka wrote: > > > On Thu, 16 Nov 2006, Ravi Periasamy wrote: > >> Dear PGSQL-JDBC Team, >> Could you please let me know if the support for "Named Parameters" >> in the >> JDBC driver is slated for some future release? >> > > Just recently I noticed an overlooked patch that implements this: > http://archives.postgresql.org/pgsql-jdbc/2006-07/msg00011.php > > The suggested patch isn't quite right, but its approach can work in > many cases. If functions are not overloaded then a simple lookup > of parameter names by the function name would work. If the > function is overloaded we might be able to use the parameter type > given by setXXX to try and determine what function we're actually > calling, but it's probably better to just error out in that case. > > Kris Jurka > > ---------------------------(end of > broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq >