Skip to Content

Issues while passing Input Parameter from a URL to a SELECT statement

hi Team,

I am developing an XS JS Application in which the following is needed:

the User through a link passes the value of the Customer Id and the XS JS application reads this Input Parameter and uses it in a SELECT statement dynamically to fetch the corresponding Customer details(say eg., CITY of the Customer).

I attempted the following ways and all of them failed and getting HTTP error 500:

1)var pstmt = conn.prepareStatement( "SELECT CITY FROM MYSCHEMA.MYTABLE WHERE CUSTOMER_ID = ?" ); and

passed the '?' value as : pstmt.setInteger(1,$.request.parameters.get("custid"));

2)var custid = $.request.parameters.get("custid");


var rs = pstmt.executeQuery(query);

Please let me know if there is a way out of this issue. if yes, what is to be done to fetch the Customer details(CITY) for a particular customer(which is coming from the Input Parameter in the LINK/URL)?

Thanks in advance for your help in advance.



Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Aug 20, 2015 at 05:56 PM

    Version 1 should be the better solution (because of SQL injections).

    I copied your code, tried to execute it and as expected I got the following message:

    "Error: PreparedStatement.setInteger: expected int for second argument, but got: string"

    First convert your parameter to an integer and then pass it into the setInteger method:

    pstmt.setInteger(1, parseInt($.request.parameters.get("custid")));

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.