I have a sql query like this.
select \"DEPT\".\"DEPTNO\" as \"DEPTNO1\",
\"DEPT\".\"DNAME\" as \"DNAME1\",
\"DEPT\".\"LOC\" as \"LOC1\",
\"EMP\".\"COMM\" as
replace :deptno
in your query with a ?.
and instead of instantiating statement use the following:
PreparedStatement stmt=con.prepareStatement(query);
stmt.setInt(1,deptno); //1 is for the first question mark
where deptno
holds the value for which you want to execute the query.
Through PrepredStatement interface we can use parametrized query which is compiled only once and has performance advantage in comparison to the Statement interface.