File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need technical guidance to solve my issue

 
Sandeep Swaminathan
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Sandeep Swaminathan
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
" 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
Posts: 338
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic