|
Posted - 11/26/2005 : 13:03:24
|
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
|
|
|
|
Posted - 11/26/2005 : 13:07:10
|
> 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
|
|
|
|
|