title: Issue with exporting portgresql table to CSV in JDBC
body: <p>I'm using postgresql to host my database. In my database, I have a table say xyz whose structure is as shown below</p>
  
  <pre><code>id    content    folder
  1     hello      Inbox
  2     hi         Sent
  </code></pre>
  
  <p>I want to export this table to CSV using my java program. The code snippet is below</p>
  
  <pre><code>Connection connection2  = new ServerDBConnect().getConnection();
  PreparedStatement statement = connection2.prepareStatement("copy (SELECT * FROM xyz WHERE folder=? ) to 'C:/export.csv' delimiter ','");
  statement.setString(1, FOLDER_SELECTED); //Here, FOLDER_SELECTED=Inbox
  statement.execute();
  </code></pre>
  
  <p>When I execute this code, I'm getting <code>SQLException</code> saying</p>
  
  <pre><code>ERROR: there is no parameter $1
  </code></pre>
  
  <p>If I execute the code without folder specified (<code>"copy (SELECT * FROM xyz) to 'C:/export.csv' delimiter ','")</code>), the code works fine.</p>
  
  <p>What am I doing wrong here? How to go about this problem?</p>
  
  <p>Note: If I execute the query (<code>copy (SELECT * FROM xyz WHERE folder='Inbox' ORDER BY time) to 'G:/export.csv' delimiter ','</code>) directly in the Postgresql SQL console, I'm getting the desired output.</p>
  
  <p>Please help</p>