Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DirectQuerySender query without parameters fails if parameters are defined in pipe #1098

Closed
ricardovh opened this issue Sep 25, 2020 · 4 comments · Fixed by #1199 or #1203
Closed

DirectQuerySender query without parameters fails if parameters are defined in pipe #1098

ricardovh opened this issue Sep 25, 2020 · 4 comments · Fixed by #1199 or #1203
Assignees
Labels

Comments

@ricardovh
Copy link
Contributor

Describe the bug
When using a DirectQuerySender with parameters defined, it fails with the following message if the query does not require any parameters:
got exception sending message: (SQLException) SQLState [99999], errorCode [17003]: Invalid column index

In the logging this is shown:
2020-09-25 14:50:35,954 DEBUG [http-bio-80-exec-5] [mid [testmessage0a7215b8-5269be6c_174c55049bd_-7ffe]] util.JdbcUtil - jdbc parameter [1] applying parameter [ID] value [null]

Executing the same query via Execute Query does not give any problems, so it really is something with the DirectQuerySender.

The reason the DirectQuerySender has parameters but can get a query that does not require any, is because it is part of an API where all url parameters are optional. To allow database optimization, the database query is generated to only use the url parameters that are actually provided, which might result in a query without any parameters.

Reporter
Ricardo

Category
Use following Tags to categorize your bug report

  • Frank Framework

To Reproduce
Steps to reproduce the behavior:

  1. Have an adapter with 1 DirectQuerySender and at least 1 parameter
  2. Send a query via Test a Pipeline
  3. Get error

Expected behavior
The query to be executed as is.

Screenshots
N/A

Environment:

  • Application server (f.e. Tomcat/WebSphere/JBOSS/Jetty): Tomcat
  • Browser [e.g. chrome, safari]: Chrome
  • Database: Oracle
  • IAF Version [e.g. 7.5 RC3, 7.6]: 7.6-20200925.120005

Additional context
N/A

@ricardovh ricardovh added the Bug label Sep 25, 2020
@gvanbrakel
Copy link
Contributor

To solve this, the JdbcQuerySender should retrieve the number of parameters from the prepared query, and may be even apply the parameters by name instead of by position

@ricardovh
Copy link
Contributor Author

In my configuration I already apply them by name via useNamedParams.

@gvanbrakel
Copy link
Contributor

The problem is in MessageSendingPipe, that tries to pass on pipe parameters to the sender by overriding the addParam() method. This fails when the pipe parameters are specified before the sender itself. This will be fixed shortly. Workaround is to specify the pipe-parameters as Sender parameters, or after the sender.

@ricardovh
Copy link
Contributor Author

I already define them as Sender parameters, so the workaround would not work.

For my configurations I found a way around this issue as there is a parameter that is present in all queries which was already set in the .xslt that made the query (integer, so no risk of injection), I changed that so that the sender also has to set that parameter.

gvanbrakel pushed a commit that referenced this issue Oct 26, 2020
* Allow Larva inline messages

* Fix #1098 forward pipe parameters, and add tests for named parameters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants