• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need technical guidance to solve my issue

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic