0

I am working with query "select * from account in (?)"

I using preparedstatement+select query+ in clause. I want to provide multiple accounts of String type. I have tried it by using Stringbuilder but it did not worked.

    Stringbuilder inclause = new Stringbuilder();
    inclause.append("123");
    inclause.append("345")
    
    Statement.setString(inclause.toString())

This code is not working for me because this is forming query like:

select * from account in ('123, 345')

and this is not correct query as I require like:

select * from account in ('123', '345')

Could you please help me in achieving this?

1 Answers1

-2
Stringbuilder inclause = new Stringbuilder();
inclause.append("'123'");
inclause.append(",");
inclause.append("'345'");
Statement.setString(inclause.toString());

Add single quotes in string and also add append ","

Dinesh Ganesan
  • 115
  • 1
  • 11