Results 1 to 5 of 5
  1. #1
    IDForums is offline Member
    Join Date
    Sep 2009
    Posts
    5
    Rep Power
    0

    Default Input file parsing to insert into DB

    Hi,

    I have a sample input file as follows:

    ++++++++++ 2009-09-28 15:10:58 ++++++++++++++
    ++++++++ DAILY SCORES +++++++++++++++++
    2009-09-28 15:10:58|AAAA|0
    2009-09-28 15:10:58|BBBBB|0
    2009-09-28 15:10:58|ACCCC|0
    ++++++++ MONTHLY SCORES +++++++++++++++++
    2009-09-28 15:10:58|AAAA|30
    2009-09-28 15:10:58|BBBBB|50
    2009-09-28 15:10:58|ACCCC|60

    I should ignore first line and then look for "DAILY SCORES" or "MONTHLY SCORES"string. This determines which MySql table has to be used.
    Then read the following lines delimited by pipe and insert them into MySql table

    Table schema is as follows:
    ------------------------------------------------------------
    dateandtimestamp | program | score
    ------------------------------------------------------------

    Please suggest the best approach to do this.

    Thanks,
    Mona.
    Last edited by IDForums; 09-29-2009 at 04:25 PM.

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Create a Record class that encapsulates the data.
    Then create a DBRecord class that holds a Set<Record> and the scores type (Daily or Monthly).
    Then create a DBRecordBuilder class that reads the file and creates a Set<DBRecordBuilder>.
    That should get you going.

  3. #3
    IDForums is offline Member
    Join Date
    Sep 2009
    Posts
    5
    Rep Power
    0

    Default

    Can you please elaborate it more? Could you please give me a skeleton of the program?
    Last edited by IDForums; 09-29-2009 at 05:10 PM.

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    No and No.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default

    r035198x has given you more than enough to start with.

    I will, however, add the IO tutorials.

Similar Threads

  1. HTML FILE parsing.
    By makpandian in forum New To Java
    Replies: 8
    Last Post: 11-02-2010, 03:00 PM
  2. Help! - How to insert a new line to a text file
    By matpj in forum New To Java
    Replies: 13
    Last Post: 02-24-2010, 05:28 PM
  3. retain value of input type file in a jsp file while being dynamically generated
    By nidhi c in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 09-27-2009, 02:21 AM
  4. Replies: 3
    Last Post: 02-28-2009, 09:17 AM
  5. Parsing XML File
    By rstar7 in forum XML
    Replies: 1
    Last Post: 10-10-2008, 03:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •