 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Frank Guest
|
Posted: Wed Jun 16, 2004 11:36 am Post subject: PreparedStatement and IN Operator ??? |
|
|
Hi ng,
i created a SQL statement that uses the IN operator.
How can i use that statement in a PreparedStatement?
SELECT FROM USER WHERE NAME IN (?)
Which setter do i have to use for a list like e.g.
? = 'Smith', 'Wesson'
ps.setString(1, "'Meier', 'Müller'") doesn't work, that would bei
SELECT FROM USER WHERE NAME IN (''Meier', 'Müller'')
Can i use setArray()?
Frank
|
|
| Back to top |
|
 |
Lee Fesperman Guest
|
Posted: Wed Jun 16, 2004 9:32 pm Post subject: Re: PreparedStatement and IN Operator ??? |
|
|
Frank wrote:
| Quote: |
Hi ng,
i created a SQL statement that uses the IN operator.
How can i use that statement in a PreparedStatement?
SELECT FROM USER WHERE NAME IN (?)
Which setter do i have to use for a list like e.g.
? = 'Smith', 'Wesson'
ps.setString(1, "'Meier', 'Müller'") doesn't work, that would bei
SELECT FROM USER WHERE NAME IN (''Meier', 'Müller'')
Can i use setArray()?
|
Generally, ? parameters can only be used with scalar data values (single values). Some
JDBC drivers may support alternate forms or setArray().
--
Lee Fesperman, FirstSQL, Inc. (http://www.firstsql.com)
==============================================================
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS (http://www.firstsql.com)
|
|
| Back to top |
|
 |
Lionel Guest
|
Posted: Thu Jun 17, 2004 8:57 am Post subject: Re: PreparedStatement and IN Operator ??? |
|
|
Frank wrote:
| Quote: | Hi ng,
i created a SQL statement that uses the IN operator.
How can i use that statement in a PreparedStatement?
SELECT FROM USER WHERE NAME IN (?)
Which setter do i have to use for a list like e.g.
? = 'Smith', 'Wesson'
ps.setString(1, "'Meier', 'Müller'") doesn't work, that would bei
SELECT FROM USER WHERE NAME IN (''Meier', 'Müller'')
|
create your request like this and it will work fine:
SELECT FROM USER WHERE NAME IN (?,?,?,...........)
or try hibernate.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|