
Untitled
By: a guest on
Apr 24th, 2012 | syntax:
None | size: 0.67 KB | hits: 13 | expires: Never
Issue with exporting portgresql table to CSV in JDBC
id content folder
1 hello Inbox
2 hi Sent
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();
ERROR: there is no parameter $1
Connection connection2 = new ServerDBConnect().getConnection();
PreparedStatement statement = connection2.prepareStatement("copy (SELECT * FROM xyz WHERE folder='" + FOLDER_SELECTED + "' ) to 'C:/export.csv' delimiter ','");