File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Need technical guidance to solve my issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Need technical guidance to solve my issue" Watch "Need technical guidance to solve my issue" New topic
Author

Need technical guidance to solve my issue

Sandeep Swaminathan
Ranch Hand

Joined: Apr 23, 2008
Posts: 52
I have a text file with enormous amount of data say around 150 columns. The data needs to be uploaded in a DB Server. I want to develop an UI in Java which can upload them into the DB Server.
I'm thinking of having a 'Browse' button which opens a window to search and load the text file and a 'Add' button which on clicking adds the columns into the DB Server.

I wonder how do I go about to solve this issue? Help me out!
[ January 02, 2009: Message edited by: Sandeep Swaminathan ]

Music is all around us. All you have to do is just LISTEN to it,
Sandeep Swaminathan
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

This is a fairly vague question so I'm afraid I can only give a fairly vague answer. Swing will give you all the GUI components you ask for: buttons, file choosers etc. Communicating with a server can be done with the classes in java.net. And JDBC is the API to communicate with a database.

What have you written so far? Or are you not even sure how to start?

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Sandeep Swaminathan
Ranch Hand

Joined: Apr 23, 2008
Posts: 52
Hey Paul,
Nice to hear from you all the details! Well, I have the entire data in a text file and I have uploaded them into the database server manually using LOAD DATA INFILE command. My requirement is a JavaUI( say SWING UI) which does it on its own on a button click. For instance, with JDBC's one can Select, Insert, Update data into the database sever. Can you do the same with those data which are present in a text file. Like designing a Swing application with buttons and on clicking it can send the data from the text file to the database server? Am I sounding clear now dude?
Kumaresh Vidhyasagar
Ranch Hand

Joined: Dec 05, 2008
Posts: 30
You can have an stored procedure in your db with this command 'LOAD DATA INFILE'. Then you can execute the stored procedure from java by passing the filename and path.
Sandeep Swaminathan
Ranch Hand

Joined: Apr 23, 2008
Posts: 52
Kumar my friend,

Thanks a lot! I tried it and it worked. Also I wrote a small program and used load data command in it! I also got another query ... How do you avoid making duplicate entries while loading the data from text file? Because if I upload the same text file, it does and is populating database with duplicate entries! How to avoid that?
Kumaresh Vidhyasagar
Ranch Hand

Joined: Dec 05, 2008
Posts: 30
" How do you avoid making duplicate entries while loading the data from text file? Because if I upload the same text file, it does and is populating database with duplicate entries! How to avoid that? "



For that, you need to have to have to have your database design proper with primary key constraint set.
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
Kumaresh Vidhyasagar wrote:" How do you avoid making duplicate entries while loading the data from text file? Because if I upload the same text file, it does and is populating database with duplicate entries! How to avoid that? "



For that, you need to have to have to have your database design proper with primary key constraint set.


Add unique constraint to one of your natural keys in the database table or do a select on the natural key to see if it exists before the insert (less efficient).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need technical guidance to solve my issue
 
Similar Threads
No more data to read from socket.
Table pop-up on click
to add new row with checkbox selected...
how access the DSN which is in other system
visible unvisible jtable column