How to import an .csv file into the database?

and can we code the program in JSP to import the.csv file into the database.

It is better to use Java class to read the CSV file and store the contents in the database.
You can use JSP to upload the CSV file to the server if you want, but don't use it to perform database operations.
JSPs are good for displaying information on the front-end, and for displaying HTML forms, there are other technologies more suitable for the middle layer, back end and the database layer.
So break you application into
1) Front end - JSPs to display input html forms and to display data retrieved from the database.
2) Middle layer - Servlets and JavaBeans to interact with JSPs. The code that reads the CSV file to parse it's contents should be a Java Class in the middle layer. It makes use of Java File I/O
3) Database layer - Connects to the database using JDBC (Java Database Connectivity), and then writes to the database with SQL insert statements.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Keeping the above concepts in mind, first build a simple JSP and get it to work,
then research on Google , for Java File I/O , discover how to read a file,
Then search on how to readh a CSV file using Java.
After researching you should be able to read the CSV file line by line and store each line inside a Collection.
Then research on Google, on how to write to the database using JDBC
Write a simple program that inserts something to a dummy table in the database.
Then, read the data stored in the Collection, and write insert statements for each records in the collection.

Similar Messages

  • How to import a XML file into the document?

    Hai,
    i had created a table using xml file....
    Now i want to import that xml file tabel into the document...
    Can any one tell me how to import the xml file into the document?
    thanks
    senthil

    Hai...
    this is senthil...
    i'm beginner for creating adobe indesign plugins..
    i want to import a html file in the document...
    i want to create a table by using html tags and
    that table will be imported into the document..
    How shall i do it?
    can any one plzz explain me?

  • How to import jar & exp file into the eclipse 3.1 + jcop

    hi, I am new to the javacard technology.
    I have implementing applet by using eclipse 3.1 + jcop plugin.
    recentlly, i got jar and exp file from someone. and I have to import given two files in the my applet.
    Q1. but i don't know how to use(import) two files into the elipse.
    and...
    I have tried to put the export file structure in the build path, but I am still getting the same error:
    Q2. "resolving constant-pool of clazz cash/ccash; failed: no such clazz cash/ccash;", what means?
    anyone help me~plz!
    many thanks..
    lsh.
    Message was edited by:
    neonoble

    1) In the Package explorer right-click the project you want to import the jar files into.
    2) Click import
    3) Select Archive file in the Import dialog box and click next
    4) Browse to the jar file and select it
    Socx

  • How to load a XML file into the database

    Hi,
    I've always only loaded data into the database by using SQL-Loader and the data format was Excel or ASCII
    Now I have to load a XML.
    How can I do?
    The company where I work has Oracle vers. 8i (don't laugh, please)
    Thanks in advance!

    Hi,
    Tough job especially if the XML data is complex. The have been some similar question in the forum:
    Using SQL Loader to load an XML File -- use 1 field's data for many records
    SQL Loader to upload XML file
    Hope they help.
    Regards,
    Sujoy

  • How to read a CSV file into the portal

    hi all,
    I want to read the content of CSV file that is avaliable in my desktop.
    plz help me with suitable code
    Regards
    Savitha
    Edited by: Savitha S R on Jun 1, 2009 8:25 AM

    Please use this code for that
    REPORT  znkp_upload_csv line-size 400.
    DATA : v_filename TYPE string.
    PARAMETER : p_file LIKE rlgrap-filename DEFAULT 'C:\Documents and Settings\Administrator\Desktop\JV.csv' .
    *Types for Reading CSV file
    TYPES : BEGIN OF x_csv,
              text(400) TYPE c,
            END OF x_csv.
    *Global internal table for reading CSV file
    DATA : lt_csv TYPE TABLE OF x_csv.
    *Global work area for reading CSV file
    DATA : wa_csv LIKE LINE OF lt_csv.
    v_filename = p_file.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                      = v_filename
      FILETYPE                      = 'ASC'
      HAS_FIELD_SEPARATOR           = ' '
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
      VIRUS_SCAN_PROFILE            =
      NO_AUTH_CHECK                 = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      TABLES
        data_tab                      = lt_csv
    EXCEPTIONS
       file_open_error               = 1
       file_read_error               = 2
       no_batch                      = 3
       gui_refuse_filetransfer       = 4
       invalid_type                  = 5
       no_authority                  = 6
       unknown_error                 = 7
       bad_data_format               = 8
       header_not_allowed            = 9
       separator_not_allowed         = 10
       header_too_long               = 11
       unknown_dp_error              = 12
       access_denied                 = 13
       dp_out_of_memory              = 14
       disk_full                     = 15
       dp_timeout                    = 16
       OTHERS                        = 17
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    DATA : BEGIN OF item OCCURS 0 ,
            t1(20) TYPE c,
            t2(20) TYPE c,
            t3(20) TYPE c,
            t4(20) TYPE c,
            t5(20) TYPE c,
            t6(20) TYPE c,
            t7(20) TYPE c,
            t8(20) TYPE c,
           END OF item.
    DATA : txt(1) TYPE c. " 1-Header 2-Item
    LOOP AT lt_csv into wa_csv.
    split wa_csv-text at ',' into item-t1
                                  item-t2
                                  item-t3
                                  item-t4
                                  item-t5
                                  item-t6
                                  item-t7
                                  item-t8.
    append item.
    clear item.
    ENDLOOP.
    Check ITEM TABLE
    Regards
    Naresh

  • How to import from CSV file into INTERVAL DAY TO SECOND column?

    Hello,
    I need to import data from a csv file that has a column that stores time-intervals (e.g. 2:06:02 Hours:Minutes:Seconds) into a table column INTERVAL DAY TO SECOND.
    Does any of you know what format I should apply?
    I tried HH:MI:SS but it didn't work.
    Any suggestion is welcomed (including changing the column type to something else that might hold time-intervals in it....).
    Thanks,
    Andrei

    Andrei,
    There is no native support for the INTERVAL datatype in the Text loading facilities of Application Express.
    To work around this known limitation, I suggest either creating a temporary table or a shadow column in your existing table. You could then upload your data for the interval as a VARCHAR2 and then use SQL to convert to an appropriate interval value.
    For example:
    1) Create a table with:
    create table foo (id number primary key, i interval day to second, shadowi varchar2(4000) )2) Using your sample data set, load this data into table FOO, loading the second column of this data into column SHADOWI
    1     01:06:02
    2     02:06:02
    3     03:01:013) Issue the following SQL to convert the value in your shadow interval column to your actual interval column
    update foo set i = to_dsinterval( '0 ' || shadowi )Note that you'll need to prepend the '0' to formulate a valid interval literal value.
    Joel

  • How to load excel-csv file into oracle database

    Hi
    I wanted to load excel file with csv extension(named as trial.csv) into
    oracle database table(named as dept),I have given below my experiment here.
    I am getting the following error,how should I rectify this?
    For ID column I have defined as number(5) datatype, in my control file I have defined as interger external(5),where as in the Error log file why the datatype for ID column is comming as character?
    1)my oracle database table is
    SQL> desc dept;
    Name Null? Type
    ID NUMBER(5)
    DNAME CHAR(20)
    2)my data file is(trial.csv)
    ID     DNAME
    11     production
    22     purchase
    33     inspection
    3)my control file is(trial.ctl)
    LOAD DATA
    INFILE 'trial.csv'
    BADFILE 'trial.bad'
    DISCARDFILE 'trial.dsc'
    APPEND
    INTO TABLE dept
    FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    (ID POSITION(1:5) INTEGER EXTERNAL(5)      
    NULLIF ID=BLANKS,
    DNAME POSITION(6:25) CHAR
         NULLIF DNAME=BLANKS
    3)my syntax on cmd prompt is
    c:\>sqlldr scott/tiger@xxx control=trial.ctl direct=true;
    Load completed - logical record count 21.
    4)my log file error message is
    Column Name Position Len Term Encl Datatype
    ID           1:5 5 , O(") CHARACTER
    NULL if ID = BLANKS
    DNAME 6:25 20 , O(") CHARACTER
    NULL if DNAME = BLANKS
    Record 1: Rejected - Error on table DEPT, column ID.
    ORA-01722: invalid number
    Record 21: Rejected - Error on table DEPT, column ID.
    ORA-01722: invalid number
    Table DEPT:
    0 Rows successfully loaded.
    21 Rows not loaded due to data errors.
    0 Rows not loaded because all WHEN clauses were failed.
    0 Rows not loaded because all fields were null.
    Bind array size not used in direct path.
    Column array rows : 5000
    Stream buffer bytes: 256000
    Read buffer bytes: 1048576
    Total logical records skipped: 0
    Total logical records read: 21
    Total logical records rejected: 21
    Total logical records discarded: 0
    Total stream buffers loaded by SQL*Loader main thread: 0
    Total stream buffers loaded by SQL*Loader load thread: 0
    5)Result
    SQL> select * from dept;
    no rows selected
    by
    balamuralikrishnan.s

    Hi everyone!
    The following are the steps to load a excell sheet to oracle table.i tried to be as simple as possible.
    thanks
    Step # 1
    Prapare a data file (excel sheet) that would be uploaded to oracle table.
    "Save As" a excel sheet to ".csv" (comma seperated values) format.
    Then save as to " .dat " file.
    e.g datafile.bat
    1,Category Wise Consumption Summary,Expected Receipts Report
    2,Category Wise Receipts Summary,Forecast Detail Report
    3,Current Stock List Category Wise,Forecast rule listing
    4,Daily Production Report,Freight carrier listing
    5,Daily Transactions Report,Inventory Value Report
    Step # 2
    Prapare a control file that define the data file to be loaded ,columns seperation value,name and type of the table columns to which data is to be loaded.The control file extension should be " .ctl " !
    e.g i want to load the data into tasks table ,from the datafile.dat file and having controlfile.ctl control file.
    SQL> desc tasks;
    Name Null? Type
    TASK_ID NOT NULL NUMBER(14)
    TASK_NAME VARCHAR2(120)
    TASK_CODE VARCHAR2(120)
    : controlfile.ctl
    LOAD DATA
    INFILE 'e:\datafile.dat'
    INTO TABLE tasks
    FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    (TASK_ID INTEGER EXTERNAL,
    TASK_NAME CHAR,
    TASK_CODE CHAR)
    The above is the structure for a control file.
    Step # 3
    the final step is to give the sqlldr command to execute the process.
    sqlldr userid=scott/tiger@abc control=e:\controlfile.ctl log=e:\logfile.log
    Message was edited by:
    user578762

  • How to import a CSV file into Appleworks

    Does anybody knows? I tried using ASCII format (everything goes into one cell), Excel (not recognized). Very fustrated, I can do that in 2 seconds with Excel or Open Office.
    Any help will be really appreciated, must be something really sily

    Roger, you are right. But instead of using a word processort I fixed the file with Perl (much faster in my case):
    auyan:~/Desktop josevnz$ perl -p -i -e 's#,#\t#g; s#\n#\rn#;' 401k-funds-appleworks.csv
    I have to say than Appleworks ***** big time .
    Thanks for your help, very valuable tip!

  • Importing a CSV file into AD 2012r2

    Hi Guys
    Just wondering if anyone can help, I am a newbie on scripting and finding it really difficult to understand how to import a csv file into AD
    I have created the CSV file with the following headers, see below but I am unable to write a powershell script to import them into AD which work, I have tried multiple help guides but still cannot do it for the life of me.
    Any help on this would be really appreciated 
    objectClass user
    cn Jo bloggs
    givenName jo
    sn blogs
    mail [email protected]
    sAMAccountname j.blogs
    AccountPassword Pa$$w0rd
    ChangePasswordAtLogon true
    PasswordNeverExpires false
    ou OU=staff,DC=test,DC=com

    Import-Csv C:\User.csv| %{New-ADUser -SamAccountName $_.SamAccountName `
    -UserPrincipalName $_.userprinicpalname `
    -Name $_.name `
    -Mail = $_.mail `
    -DisplayName $_.name `
    -GivenName $_.GivenName `
    -Path "OU=Test Users,DC=XXX,DC=XXX" `
    -PasswordNeverExpires $false `
    -ChangePasswordAtLogon $true `
    -AccountPassword (ConvertTo-SecureString "test41;" -AsPlainText -force) `
    -Enabled $True -PasswordNeverExpires $True -PassThru ` }
    help New-ADUser -Examples
    You can try the below sample code
    Regards Chen V [MCTS SharePoint 2010]

  • How to create power shell script to upload all termset csv files into the SharePoint2013 local taxonomy ?

    Hi Everyone,
    I want to create a powershell script file
    1) Check a directory and upload all termset csv files into the SharePoint local taxonomy.
    2) Input paramaters - directory that containss termset csv files, Local Termstore to import to,
    3) Prior to updating get a backup of the existing termstore (for rollback/recovery purposes)
    4) Parameters should be passed in via XML file.
    Please let me know how to do it.
    Regards,
    Srinivas

    Hi,
    Please check this link
    http://termsetimporter.codeplex.com/
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • How do you import a .png file into the Final Cut Pro X and at the same time keep the file's original transparency settings?

    How do you import a .png file into the Final Cut Pro X and at the same time keep the file's original transparency settings?

    Go to the Info inspector for the still image and in settings select the alpha type.

  • How to import a PSD file into Indesign WITH layers so it can be edited/saved as an InDesign file?

    How to import a Photoshop file into Indesign CS6 so that it's layers show in InDesign and it can then be edited/saved as an InDesign file?

    MyTienN wrote:
    Someone had mentioned the possibility of saving each individual layer in Photoshop as a png file and importing into Indesign and adjusting it in there
    What do you mean by "adjust"? Editing of Photoshop images should be done in Photoshop.
    Sure, it's possible to save individual layers from an image in Photoshop as inidvidual files in a variety of formats, but what's the point? You could just as easily import the layered file, then copy/paste it into a new layer for each layer in the image and use layer visibility to control which ones show. I don't think that will do you a lot of good, though, if you use adjustment layers or opacity controls on the layer in Photoshop.

  • Importing a csv file into addressbook

    So I did a search & found this question has come up quite often, but with the person having a slightly different problem, so here goes.
    I am trying to import a csv file into address book, when I go import -> text tile it comes up like it should do and I pick the file, if I select ok at this point, it will quite happily import all of the data no trouble (but in the wrong categories). So I make the changes to what I want ie. Phone other --> Phone (work). Then when I click ok, the button goes from blue to white but nothing happens.
    When I open the csv file in textedit I can see all the values separated by commas.
    Any Ideas?

    I too just had this problem. To clarify all fields work and you can map them. I found that the Outlook CSV file had two problems which were tripping up the AddressBook import function. Note these were both in street address fields so I suspect the poster who said that addresses don't work may have been having that problem.
    The CSV load program does not work if you have commas "," in your data. In my case this was very common for some European addresses as well as some company names. And then the second problem was if there was a carriage return or new line character in a field. This later one was a problem with the address fields. I suspect an AddressBook export to CSV might have this same issue. Specifically, when there were multiple lines to the street address, they had been entered as multiple lines in street address one, as opposed to entering them in multiple fields such as "street 1", "street 2", etc.
    To solve the problem I opened the CSV file using Numbers and did a global find and replace on: commas, substituting the string --- and on the newline character "¶" (ALT+Rreturn) with *.
    Note to reduce some of the remapping I also changed all of the labels with "business" in the header row of the CSV file to "work". This made it a little easier for the AddressBook import function to map fields more correctly.
    After these set of changes rather than the alternating blue then white with nothing behavior it cleanly loaded all of my names. I could then search for "---" and "*" in addressbook's search field to identify all addresses which I had to clean up.
    I hope that is helpful to someone else. The import function really does work. However, it is not robust enough to deal with certain oddities in one's data.

  • Import a CSV-file into a new table?

    hi, im trying to import a csv file into a new tabel, but i just cant make it work :-O. what are the steps to do that? im using sql developer version1.1.2.25.
    thanks for helping :-)

    We do not support CSV import at this stage, we only support XLS import.
    Regards
    Sue

  • How do I get my file into the time line in Premiere Pro CC?

    How do I get my file into the time line in Premiere Pro CC? I am use to Premier Pro CS6 and unfortunately my labtop took a crash and I lost all of my adobe products. I wanted to check out a trial version and I cannot seem to find one for CS6! Please Help Me! My project is due tonight!!!!!

    Hi Aneumann,
    Welcome to the Forums.
    You have to just right click on the clip imported, in the project panel and select new sequence from clip. You can also go to file menu>new>sequence and create a sequence and then drag the clips after importing them , into the timeline.
    Regards,
    Vinay

Maybe you are looking for