I have the procedure where i want to pass the exact values from jdbc that is passed from user after query format.
but when i am using preparedstatement with $$ it gives me an error saying :
org.postgresql.util.PSQLException: The column index is out of range: 3, number of columns: 2.
however without $$ it's working perfectly fine.please help me how to pass argument with $$ with preparestatement?
conn = DriverManager.getConnection(jdbcUrl, username, password);
String prepareselectSQL="SELECT get_sum(?,?,$$?$$)";
stmt=conn.prepareStatement(prepareselectSQL);
stmt.setInt(1,10);
stmt.setInt(2,200);
stmt.setString(3,"");
rs = stmt.executeQuery();
while (rs.next()) {
System.out.println(rs.getString(1));
}
see below is my example query:
select * from getdashboarddata_010('application','(upload + download)',?,'2018-02-05 00:00:00','2018-02-05 00:00:00','0','5-1','','hits','desc','','true');
below is the value which needs to replace with ? :
(select * , ''::text as srczonename, ''::text as srczonetype, ''::text as firewall_cat_type, ''::text as destzonename, ''::text as destzonetype , null::int as appresolver from fwapp_applicationutfv5_12hr ) fwapp_applicationutfv5_12hr where "5mintime" >='2018-05-04 00:00:00' and "5mintime" < '2018-05-04 23:59:59'
so,you can see my value already contains single quotes for that reason i need to pass this with dollar quoting within prepare statement.