Etantonio Electronic
Welcome to the forum.
Username:
Password:
Save Password


Register
Select Language

Forgot your Password?
 
Active Topics | Active Polls | Members | Online Users | Avatar Legend | Search
Select Skin: 
 All Forums
 Informatics
 Java
 Prepared statement with a problem
   All users can post NEW topics in this forum
   All users can reply to topics in this forum
Rating is not allowed for this topic.
 Printer Friendly
Author  Topic   

etantonio

Status: offline

 Posted - 11/26/2005 :  13:03:24  Show Profile  Visit etantonio's Homepage  Add etantonio to Buddylist
Good Morning,
I've this prepared statement


PreparedStatement pstm =
" select domicilio from anagrafe where id_struttura IN (?) "
pstm.setString(1, " '60' , '12' , '85' , '45' ");


it seems that the ' in the string inserted like a parameter is a problem
how can I solve this ?? I've a variable number of values inside the IN.


Thanks


Antonio D'Ottavio
www.etantonio.it/en/

Why not ?!?

 Country: Italy  ~  Posts: 26  ~  Member Since: 10/21/2005  ~  Last Visit: 11/17/2008 Alert Moderator 

Scorpio

Status: offline

 Posted - 11/26/2005 :  13:07:10  Show Profile  Add Scorpio to Buddylist
> Good Morning,
> I've this prepared statement

> PreparedStatement pstm =
> " select domicilio from anagrafe where id_struttura IN (?) "
> pstm.setString(1, " '60' , '12' , '85' , '45' ");



You're passing a string (i.e, a Varchar /CHAR parameter from dbms point of
view), while it's expecting an enumeration of values.


> it seems that the ' in the string inserted like a parameter is a problem
> how can I solve this ?? I've a variable number of values inside the IN.


Try with :

Statement st = connection.createStatement();
String sql = " select domicilio from anagrafe where id_struttura IN "
String restriction = " ( '60' , '12' , '85' , '45' ) ";
sql += restriction;
ResultSet rs = st.executeQuery(sql);


Hope it helps.


Scorpio.

 Country: Norway  ~  Posts: 3  ~  Member Since: 11/26/2005  ~  Last Visit: 02/12/2007 Alert Moderator  Go To Top Of Page
   Topic   
 Printer Friendly
Jump To:
 Image Forums 2001 This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000