0

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.

Santosh
  • 874
  • 11
  • 21
  • Please include the query that you are using to generate this error. It will make answering your question much easier. Also, when you say "replace a single ?", do you mean you are trying to put this data into a single column in the database? – Luke Dec 08 '17 at 16:46
  • Query: select count(*) from transaction where transactiontype in (?); and yes, i will be going to put this data into single column – Tarun Patel Dec 08 '17 at 17:13

0 Answers0