Skip to content
Advertisement

Java SQL problem executing query through CallableStatement with parameter

I have a problem in a CallableStatement that execute a stored procedure query which accept a parameter.

I have a list of string that contains the query like:

I have a list of string that contains the parameter like

I have no SQL syntax error when I run but the result set doesn’t have any value.

The expected result of the execution is that i could create an object by receiving data from the result set.

Here is the code:

I tried to manually set in cb.setString(1,cds) the value like cb.setString(1,”L-INF”) AND IT WORKS !!!

But I can’t set manually the parameter, I need to iterate with for each loop each string and dynamically insert as parameter.

Why if I set the parameter manually like a string it works instead if i give a string variable not ?

Could anyone tell me what I’m doing wrong?

Advertisement

Answer

After a lot of attempts, I’ve found the solution.

The problem is in your variable cdsbecause it could have white spaces before or after. Try:

For me it worked.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement