CSV Reader – Java for PostgreSQL

I need to load a csv to a table in the database.

Below is my table structure.

    Column    |          Type          | 
 ip_from      | bigint                 
 ip_to        | bigint                 
 country_code | character(2)           
 country_name | character varying(64) 
 region_name  | character varying(128) 

I’m using CSV Reader to read and insert the file.

CsvReader products = new CsvReader("E:test.CSV");
             while (products.readRecord())
                String ip_from = products.get("ip_from"); //int
                String ip_to = products.get("ip_to"); //int
                String country_code = products.get("country_code"); //char
                String country_name = products.get("country_name"); //char 

However, this code give me an error since the datatype for the ip_from and ip_to are different.

It should be BIGINT.

I try to use parseInt method, but it is still not working.

Source: java

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.