0

I am trying to change from Sql server to Postgres db, and I am storing data to db using SQLServerBulkCopy in sql server, for importing csv files . Is there any similar way of copying data to db, in postgres. Here is my source code for doing that in sql server:

 SQLServerBulkCSVFileRecord fileRecord = null;

        fileRecord = new SQLServerBulkCSVFileRecord(crawler.folderPath + "\\" + crawler.srcPasiv() + ".csv", true);
       // fileRecord.addColumnMetadata(1, null, java.sql.Types.NULL, 250, 0);
        fileRecord.addColumnMetadata(1, null, java.sql.Types.VARCHAR, 250, 0);
        fileRecord.addColumnMetadata(2, null, java.sql.Types.VARCHAR, 250, 0);
        fileRecord.addColumnMetadata(3, null, java.sql.Types.VARCHAR, 250, 0);
        fileRecord.addColumnMetadata(4, null, java.sql.Types.VARCHAR, 250, 0);
Shpend Palushi
  • 597
  • 8
  • 21
  • If this is a one time thing, just use the `COPY` SQL command. [SQL COPY Command](http://www.postgresqltutorial.com/import-csv-file-into-posgresql-table/). – Jason Armstrong Nov 12 '18 at 14:44
  • I should have mentioned it, it is not a one time thing,thanks – Shpend Palushi Nov 12 '18 at 14:48
  • Why are you migrating to an [unsupported](https://www.postgresql.org/support/versioning/) Postgres version? –  Nov 12 '18 at 14:57
  • 1
    The equivalent is the [CopyManager API](https://jdbc.postgresql.org/documentation/publicapi/org/postgresql/copy/CopyManager.html) see e.g. [this question](https://stackoverflow.com/questions/6958965) or [this question](https://stackoverflow.com/questions/46988855) –  Nov 12 '18 at 14:58

0 Answers0