not passing List of String as single parameters inside
preparedStatement.setObject()
I want to pass a List of String coming from request parameter to the
preparedStatement.setObject() as a single parameter. Here I am coverting
list of Objects to a single String.
So while passing this converted String to setObject method it is
converting ' to \'.
So my query is like :
select * from category where category IN (?)
for (int counter = 0; (!sqlParams.isEmpty()) && counter <
sqlParams.size(); counter++) {
System.out.println(sqlParams.get(counter));
stmt.setObject(counter + 1, sqlParams.get(counter));
System.out.println(stmt.toString());
}
here sqlParams.get(counter) is giving following value to me.
'Adult', 'Classic', 'Fantasy', 'Mystery'
but when i am using stmt.setObject(), and printing the value of stmt, it
is showing following values:
'\'Adult\', \'Classic\', \'Fantasy\', \'Mystery\'
There are other ways to solve these approach too but they are increasing
time complexity for my code. Can anyone Suggest me solution to this?
No comments:
Post a Comment