I have to pass List from java to JDBC query( which i have written in xml file).
List transactionTypeStringList which can have 3 or 6
Before passing it to query, i have joined all the list value using following code to concatenate
transactionTypeString= String.join("',' ", transactionTypeStringList);
transactionTypeString= "'"+transactionTypeString+ "'";
Query:
select count(*) from transaction where transactiontype in (?);
I am using db2 db and when i run the program, i am getting following exception:
Caused by: com.ibm.db2.jcc.am.SqlDataException: DB2 SQL Error: SQLCODE=-302, SQLSTATE=22001, SQLERRMC=null, DRIVER=3.64.96
When i googled this error code, it states that "Data being inserted into the database table column is larger than the assigned column length." which i understand since i am passing list of value to replace a single ? But now I don't how to pass multiple value from java code to jdbc to replace a single ?.
I don't want to create multiple queries(one with 3 and other with 6 value). Please help me to fix this issue.