Sql query with bind variables execution in Jdbc

前端 未结 5 1808
庸人自扰
庸人自扰 2021-01-15 17:28

I have a sql query like this.

 select \"DEPT\".\"DEPTNO\" as \"DEPTNO1\",
\"DEPT\".\"DNAME\" as \"DNAME1\",
\"DEPT\".\"LOC\" as \"LOC1\",
\"EMP\".\"COMM\" as         


        
5条回答
  •  無奈伤痛
    2021-01-15 17:58

    You created a Query with bind variable and you never set it.

    Use OraclePreparedStatement and its method setStringAtName()

    statement.setStringAtName("DeptNo","<>");
    

    If not OraclePreparedStatement, you can just put it as ?1 in your Query string and use,

    statement.setString(1,"<>");
    

    If in case, you don't know how many bind variables you get, you have capture the bind variables in a map and prepare a list and set it accordingly!

    Else your requirement is unachievable!

提交回复
热议问题