AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PreparedStatement and IN Operator ???

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases
View previous topic :: View next topic  
Author Message
Frank
Guest





PostPosted: Wed Jun 16, 2004 11:36 am    Post subject: PreparedStatement and IN Operator ??? Reply with 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()?

Frank


Back to top
Lee Fesperman
Guest





PostPosted: Wed Jun 16, 2004 9:32 pm    Post subject: Re: PreparedStatement and IN Operator ??? Reply with quote



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





PostPosted: Thu Jun 17, 2004 8:57 am    Post subject: Re: PreparedStatement and IN Operator ??? Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.