Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 24th, 2012  |  syntax: None  |  size: 0.67 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Issue with exporting portgresql table to CSV in JDBC
  2. id    content    folder
  3. 1     hello      Inbox
  4. 2     hi         Sent
  5.        
  6. Connection connection2  = new ServerDBConnect().getConnection();
  7. PreparedStatement statement = connection2.prepareStatement("copy (SELECT * FROM xyz WHERE folder=? ) to 'C:/export.csv' delimiter ','");
  8. statement.setString(1, FOLDER_SELECTED); //Here, FOLDER_SELECTED=Inbox
  9. statement.execute();
  10.        
  11. ERROR: there is no parameter $1
  12.        
  13. Connection connection2  = new ServerDBConnect().getConnection();
  14. PreparedStatement statement = connection2.prepareStatement("copy (SELECT * FROM xyz WHERE folder='" + FOLDER_SELECTED + "' ) to 'C:/export.csv' delimiter ','");