Hi,

I am trying to execute a select query using prepared statement in java. The executeQuery() method throws bind variable doesnot exist exception. Below is the code section for the same.

Code:
String var_a = "12345";
String  sql = "select distinct (SELECT Col_1 FROM Col_ATTRIBUTE WHERE  Col_2 ='AB' and Col_3 = ?) AS COL_NAME, " +  
					   "(DECODE((select distinct \"Col_1\" from Tab_1 where Col_3 = ? AND \"Col_1\" = 'Open'),'Open',1, 0)) AS COL_STAT, " +
					   "(Select SUM(\"Col_B\") from Tab_2 where Col_2 = ? AND \"Col_3\" = 'Open') AS COL_B from DUAL";

stmt = conn.prepareStatement(sql);
		counter = 0;
		try
		{
			while (counter <= 3)
			{
				stmt.setString(++counter,var_a);
			}
			log.debug("Query : " + stmt.toString());
		}
		catch (Exception e)
		{
			log.error("Exception :"+e);
		}

		try
		{
			ResultSet  rs = stmt.executeQuery();
			log.debug("After query execution..." );
				if(!rs.next())
				{
					log.debug("No records");
				} else {
				while(rs.next())
				{
					log.debug("Inside the while loop..." );
					varName = rs.getString(1);				             }
			}
		}
		catch (Exception e)
		{
			log.error("Exception :"+e);
		}
		finally
		{
			if(rs!=null){
			rs.close();
			stmt.close();
			}
		}
Please advice how to resolve this issue. I am using java1.4.