upload the csv file those records should be inserted corresponding fields of the table in the dabatase

i have a csv file in that i have  id and name columns and the corresponding values below that.my requirement is i will upload that csv file those records should be inserted corresponding fields of the table in the dabatase.how will i do this?
LVL 20
chaitu chaituAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
This should make it easier:

http://ostermiller.org/utils/CSV.html
CEHJCommented:
Some dbs can load CSV automatically btw
chaitu chaituAuthor Commented:
through java i have to do this
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

CEHJCommented:
I'd use the above with a PreparedStatement in batch mode
chaitu chaituAuthor Commented:
just tell me a psecudo code how to read csv file using CSVParser
CEHJCommented:
You don't need pseudo. There's actual code on the main page:

http://ostermiller.org/utils/CSV.html
chaitu chaituAuthor Commented:
ur talking abt this;but here how will u pass cvs file??

String[][] values = CSVParser.parse(new StringReader(""));

// Display the parsed data
        for (int i=0; i<values.length; i++){
            for (int j=0; j<values[i].length; j++){
                System.out.println(values[i][j]);
            }
            System.out.println("-----");
        }
CEHJCommented:
>>how will u pass cvs file??

You don't pass the CVS file. You insert individual values in that array into the DB
chaitu chaituAuthor Commented:
String[][] values = CSVParser.parse(new FileReader(new File("c:/chaitu/emp.csv")));

// Display the parsed data
        for (int i=0; i<values.length; i++){
            for (int j=0; j<values[i].length; j++){
                System.out.println(values[i][j]);
            }
            System.out.println("-----");
        }

in the emp.csv file i have id and name values will be stored.......
CEHJCommented:
>>
          for (int j=0; j<values[i].length; j++){
                System.out.println(values[i][j]);
            }
>>

Replace the above by

ps.setString("id", values[i][0]);
ps.setString("name", values[i][1]);
ps.addBatch();

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CEHJCommented:
(If 'id' is not a String, obviously make the appropriate adjustments)
chaitu chaituAuthor Commented:
so what i am doing is correct

String[][] values = CSVParser.parse(new FileReader(new File("c:/chaitu/emp.csv")));
CEHJCommented:
Yes
CEHJCommented:
:-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.