This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes comparing csv file values with database attributes. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "comparing csv file values with database attributes." Watch "comparing csv file values with database attributes." New topic
Author

comparing csv file values with database attributes.

Preethi Dev
Ranch Hand

Joined: Sep 07, 2008
Posts: 265
Hi Ranchers!

could anyone suggest me how to compare(mapping) the values in the csv files with the Database table attribute values?

Based on that I need to update the records or insert with the conditions.

please help me.

Regards
Preethi
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32635
    
215

Preethi,
CSV doesn't mean anything to a database so you'd have to split the row into columns. Then you can do a normal PreparedStatement update to match. Note that the merge statement in SQL lets you do an update or insert depending on whether there is already a match.


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 2238
    
  23

If you are using Oracle, then you can use external tables.

Basically, Oracle external tables allow you to define a SQL table structure over a flat file e.g. in CSV format. Because this looks like any other table inside Oracle, you can then perform SQL operations on the table e.g. to compare its contents with other tables in your database. Generally if your external table is based on a CSV file then you can only read from it within Oracle i.e. you cannot write back to the CSV file.

External tables are especially useful if you have to upload large volumes of data into your database from a flat file format such as CSV: put your file in the appropriate Oracle directory, define your external table to point to that file, then simply use SQL to SELECT the data from the external table and INSERT/MERGE it into a normal relational table in the database. This bulk loading mechanism is much faster than reading records from a CSV file e.g. in Java and using individual INSERTs to write them to the DB.

Of course, if you're not using Oracle, then you're out of luck!


No more Blub for me, thank you, Vicar.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: comparing csv file values with database attributes.
 
It's not a secret anymore!