Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / June 2004

Tip: Looking for answers? Try searching our database.

PreparedStatement and IN Operator ???

Thread view: 
Frank - 16 Jun 2004 12:36 GMT
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
Lee Fesperman - 16 Jun 2004 22:32 GMT
> Hi ng,
>
[quoted text clipped - 10 lines]
>
> 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().

Signature

Lee Fesperman, FirstSQL, Inc. (http://www.firstsql.com)
==============================================================
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS  (http://www.firstsql.com)

Lionel - 17 Jun 2004 09:57 GMT
> Hi ng,
>
[quoted text clipped - 8 lines]
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.