Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #16294

Re: JDBC, PreparedStatement and named parameters

From jebblue <n@n.nnn>
Subject Re: JDBC, PreparedStatement and named parameters
Newsgroups comp.lang.java.programmer
References <slrnk0i9rb.u9l.avl@gamma.logic.tuwien.ac.at> <500a0fcb$0$292$14726298@news.sunsite.dk> <slrnk0lg7u.u9l.avl@gamma.logic.tuwien.ac.at>
Organization Personal
Message-ID <AaOdnbdNWO6XjpPNnZ2dnUVZ_sadnZ2d@giganews.com> (permalink)
Date 2012-07-23 22:14 -0500

Show all headers | View raw


On Sat, 21 Jul 2012 14:47:26 +0000, Andreas Leitgeb wrote:

> Arne Vajhøj <arne@vajhoej.dk> wrote:
>> On 7/20/2012 5:39 AM, Andreas Leitgeb wrote:
>>> While in C/C++ eSql with ProC (not sure about correct
>>> nomenclature) I can use named variables for the parameters,
>>> jdbc seems like it would only allow positional parameters.
>>>
>>> With Google, I stumbled over this approach:
>>>    http://www.javaworld.com/javaworld/jw-04-2007/jw-04-jdbc.html
>>>
>>> which boils down to pre-processing the sql-statement, replacing
>>> the named variables by "?" while creating an array of the parameters
>>> such, that e.g. a snippet like this:
>>>     "...  :a :c :b :a ..."  and setting a -> x1, b -> x2, c -> x3
>>> would turn into
>>>     "...  ? ? ? ? ..." with an parameter array of { x1, x3, x2, x1 }
>>>
>>> That almost looks like what I was hoping for, but when I see
>>> that the article is 5 years old, then I'd hope that something
>>> similar might meanwhile have been turned into a standard...
> 
>> JDBC is designed to support all databases.
>>
>> The only JDBC driver shipping with JDK was the ODBC-JDBC
>> brudge.
>>
>> ODBC only support named parameters for SP calls not
>> for regular SQL statements.
>>
>> Possibly other database API's does not support it either.
> 
> Thanks. That explains, why this feature isn't standard in JDBC.
> Since this new Java-project is meant to work with any jdbc-
> supported DB, Oracle-extensions are a not an option here.
> 
> I must admit, that my C/C++ database background is entirely
> limited to Oracle, but that's a different story.
> 
>> You can obviously do the string manipulation stuff and
>> maybe wrap it nicely. But I assume you do not need help
>> with that.
> 
> Indeed :-)

Not in standard JDBC? java.sql.PreparedStatement.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

JDBC, PreparedStatement and named parameters Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-07-20 09:39 +0000
  Re: JDBC, PreparedStatement and named parameters markspace <-@.> - 2012-07-20 06:31 -0700
    Re: JDBC, PreparedStatement and named parameters Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-07-20 14:52 +0000
      Re: JDBC, PreparedStatement and named parameters markspace <-@.> - 2012-07-20 08:15 -0700
        Re: JDBC, PreparedStatement and named parameters Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-07-20 16:26 +0000
          Re: JDBC, PreparedStatement and named parameters markspace <-@.> - 2012-07-20 09:37 -0700
            Re: JDBC, PreparedStatement and named parameters Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-07-20 21:04 +0000
              Re: JDBC, PreparedStatement and named parameters markspace <-@.> - 2012-07-20 14:12 -0700
                Re: JDBC, PreparedStatement and named parameters Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-07-20 22:35 +0000
                Re: JDBC, PreparedStatement and named parameters markspace <-@.> - 2012-07-20 16:08 -0700
                Re: JDBC, PreparedStatement and named parameters Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-07-21 14:32 +0000
                Re: JDBC, PreparedStatement and named parameters Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-07-24 16:18 +0000
            Re: JDBC, PreparedStatement and named parameters Arne Vajhøj <arne@vajhoej.dk> - 2012-07-20 22:13 -0400
  Re: JDBC, PreparedStatement and named parameters Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-07-20 10:22 -0700
    Re: JDBC, PreparedStatement and named parameters Lew <lewbloch@gmail.com> - 2012-07-20 11:00 -0700
  Re: JDBC, PreparedStatement and named parameters Arne Vajhøj <arne@vajhoej.dk> - 2012-07-20 22:11 -0400
    Re: JDBC, PreparedStatement and named parameters Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-07-21 14:47 +0000
      Re: JDBC, PreparedStatement and named parameters jebblue <n@n.nnn> - 2012-07-23 22:14 -0500
        Re: JDBC, PreparedStatement and named parameters jebblue <n@n.nnn> - 2012-07-23 22:19 -0500
  Re: JDBC, PreparedStatement and named parameters Roedy Green <see_website@mindprod.com.invalid> - 2012-07-21 15:00 -0700
    Re: JDBC, PreparedStatement and named parameters Arne Vajhøj <arne@vajhoej.dk> - 2012-07-21 21:53 -0400

csiph-web