storing csv into oracle database

storing csv into oracle database

i want jsp code for storing csv file into oracle database

View Answers

June 22, 2011 at 2:48 PM

<%@page import="java.io.*,java.sql.*,java.util.*,jxl.*, jxl.read.biff.BiffException"%>

<%
ArrayList<String> list1=new ArrayList<String>();
ArrayList<String> list2=new ArrayList<String>();
ArrayList<String> list3=new ArrayList<String>();

    Cell rowData[] = null;
    int rowCount = 0;
    int columnCount = 0;
    int totalSheet = 0;


       WorkbookSettings ws = new WorkbookSettings();
        ws.setLocale(new Locale("en", "EN"));
       Workbook workbook = Workbook.getWorkbook(new File("C:/data.csv"), ws);

        Sheet s = workbook.getSheet(0);
        rowCount = s.getRows();
        columnCount = s.getColumns();
        for(int i = 1; i < rowCount; i++){
            rowData = s.getRow(i);
            if(rowData[0].getContents().length() != 0){ 
                for(int j = 0; j < columnCount ;j++){
                 switch(j){
                    case 0:
                        System.out.println("ID: "+rowData[j].getContents());
                        list1.add(rowData[j].getContents());
                        break;
                    case 1:
                        System.out.println("Name: "+rowData[j].getContents());
                        list2.add(rowData[j].getContents());
                        break;
                    case 2:
                        System.out.println("Address: "+rowData[j].getContents());
                        list3.add(rowData[j].getContents());
                        break;
                       }
                    }
                  }
        }
    workbook.close(); 
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/roseindia","root", "root");
Statement st=conn.createStatement();
for(int i=0;i<list1.size();i++){
    String id=list1.get(i).toString();
    String name=list2.get(i).toString();
    String address=list3.get(i).toString();
    st.executeUpdate("insert into data(id,name,address) values('"+id+"','"+name+"','"+address+"')");
}
out.println("Data is successfully inserted into the database");

%>

For the above code, you need jxl.jar and put it into the lib of jdk and apache tomcat.









Related Tutorials/Questions & Answers:
storing csv into oracle database
storing csv into oracle database  i want jsp code for storing csv file into oracle database
Uploading a Software and storing in the database
Uploading a Software and storing in the database  I want to upload a software(may be of maximum 20mb) through JSP, and store it in the database. The coding present in the site for uploading and storing in the database
Advertisements
storing xml into database - XML
storing xml into database   hi i have an xml file it contains elements with attributes as well as nested elements so how to go forward .......with it i know how to persist a simple xml file into data base but i m finding some
URGENT: Export Table in Oracle db to CSV file
URGENT: Export Table in Oracle db to CSV file  Hi, Could you basically help me by providing a program in Java. I want a program to connect and export a table in the oracle database to a folder in my local harddrive. Thankyou
File insertion into oracle database
File insertion into oracle database  How to Read and Insert a file (any format) into a Oracle database
Spring and Oracle Database
Spring and Oracle Database  I need example for Batch update process using oracle database and spring framework with full explanation
to fetch data from ms word and storing into database
to fetch data from ms word and storing into database  i want to know how to fetch datafields from ms word and storing into database??? please answer soon .its urgent
java with Oracle Database
java with Oracle Database  Hello I have been encountering a problem regarding creating a table with Oracle.When i am creating new table in the Database using Oracle , it is giving error saying an errror occured incursive sql
Oracle Database connectivity probem
Oracle Database connectivity probem  hi Below is the code of oracle database connectivity, when i compile it, it will show the error... also set the environment variable like that .;E:\oracle\ora81\jdbc\lib
Connecting Oracle database with struts - Struts
Connecting Oracle database with struts  Can anyone please provide me some solutions on Connection between Oracle database and struts
android connection to database oracle 10g
android connection to database oracle 10g  Hello, How i can connect my android application to my oracle 10g database
Oracle 9i database problem
Oracle 9i database problem  Hi Somebody has given the solution but i... Oracle 9i in my laptop.and i got sql+ page ok.i have gone to control panel->odbc->in that i correctley configured DNS and TNS and tested the Oracle
Oracle Database - Insert System Time
Oracle Database - Insert System Time  Hi I want to insert only system time dynamically using a statement but not a prepared statement into Oracle Database please suggest me any code
storing date from html form to oracle 10g using servlet
storing date from html form to oracle 10g using servlet  i have... this date month year from html form into oracle 10g database where i have..."); con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","ORS
getting and storing dropdown list in database in jsp
getting and storing dropdown list in database in jsp  i have a drop down list to select book from database. i'm able to retrieve dropdown list from... lyk this. but it storing null value in the database. :\ what to do
write excel file into the oracle database
write excel file into the oracle database  dear sir, i need the jsp code that reads the excel file and stores it into the oracle database table..and also i need the code to connect oracle database? thank u in advance
Oracle Database error - JDBC
Oracle Database error   String query11 = "SELECT product_code, product_quantity, price FROM o"+orderid; ResultSet rs11 = stmt.executeQuery(query11); while(rs11.next()){ product_code[j
storing date from html form to oracle 10g using servlet
storing date from html form to oracle 10g using servlet  i have... this date month year from html form into oracle 10g database where i have..."); con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","ORS
error oracle database connection?
error oracle database connection?  hi now i am trying to connect oracle database and also insert my data into table, but it's not working.. I created... in oracle table. my table name is logininfoclient_sla. this is my coding
Java Connection to Oracle database
Java Connection to Oracle database  HI I am ubable to connnect jdbc to Oracle database.i had gone to control panel >>Administrative tool>>>Data source,in that forDNS name i typed Oracle and in TNS i culdn't
complex xml parsing and storing in database - XML
complex xml parsing and storing in database  Hi Experts ,i want to parse my xml document and store it in mysql database. This is my code. How to parse this complex data. EDI_DC40 800 0000000000557748
oracle database backup using jsp
oracle database backup using jsp   I want to take the backup of oracle database.I want to write the code in jsp ,so that when the page is loaded a backup of the database is stored in one of my local drives.Is it possible to do
Database Connectivity Withe Oracle
Database Connectivity Withe Oracle  Develop a program to perform the database driven operation like insert, Delete, Update and select. To perform the above operations create one table named Employee. Field Name Field Type EmpId
Storing records of a file inside database table in java
Storing records of a file inside database table in java  Here is my requirement, I have a file which contains some number of records like... the records inside the database except headings (Here sid,sname,age are headings
storing records which of a file into a table of mssql database
storing records which of a file into a table of mssql database  I have a requirement like this, A file contains some records with headers same as column names of a table. I have to store those records into a table
jsp with database oracle
jsp with database oracle  hai i am doing one program in jsp i want to check the jsp life cycle methods so wrote one program, in which i write jspInit() method and jspDestroy() methods. but i am getting error i crate a table
getting problem in storing & retrieving value in database
getting problem in storing & retrieving value in database  Hello everyone i am doing a project where my back end is ms access & i want to store value like 5353250214 so if i store it as long int in access it wont take it &
About connection database oracle to java
About connection database oracle to java  Hi I culdn't connect oracle datebase to java.when i compile the program it is ok.but when i clicked... Oracle and then i clicked add button.Then Dialog box came indicating DNS and TNS
About connection database oracle to java
About connection database oracle to java  Hi I culdn't connect oracle datebase to java.when i compile the program it is ok.but when i clicked... Oracle and then i clicked add button.Then Dialog box came indicating DNS and TNS
About connection database oracle to java
About connection database oracle to java   I culdn't connect oracle... Panel>>Administrative Tools>>Data Sources in that i selected Oracle... just typed DNS as Oracle and for TNS i clicked on the list of TNS. But it has
About connection database oracle to java
About connection database oracle to java   I culdn't connect oracle... Panel>>Administrative Tools>>Data Sources in that i selected Oracle... just typed DNS as Oracle and for TNS i clicked on the list of TNS .But it has
About connection database oracle to java
About connection database oracle to java  **Hi I culdn't connect oracle datebase to java.when i compile the program it is ok.but when i clicked... Oracle and then i clicked add button.Then Dialog box came indicating DNS and TNS
Java Barcode Program with Oracle database
no and serial no of the item being scanned to Oracle 10g database. I dont have any...Java Barcode Program with Oracle database  Hi Everyone, I need help to develop my new project, am going to do with barcode s/w, am very new
How to connect to the database to my application if my database is made up in oracle
How to connect to the database to my application if my database is made up in oracle   How to connect to the database to my application if my database is made up in oracle
store & retrive the image from oracle database
store & retrive the image from oracle database  how can i store the image path in tha database & fetch that image from oracle database
related retrieving value from oracle database
related retrieving value from oracle database  how we get the value from database in the given textbox
related retrieving value from oracle database
related retrieving value from oracle database  how we get the value from database in the given textbox
storing details in database on clicking submit button - JSP-Servlet
storing details in database on clicking submit button  I am using JSP in NetBeans and have developed an application form which has fileds naming... database on clicking submit button. I am unable to do this.Can u tell me how to code
php csv file uploding into mysql database table.
php csv file uploding into mysql database table.  hai friends, i... fields. i have one mysql database table with two files fields, when ever i am uploding csv file, i want to fetch the datas in corresponding fields in table. can
reading the records from a .xlsx file and storing those records in database table
reading the records from a .xlsx file and storing those records in database... file and store that records in database table. I tried like this public class...(); String [] splitSt=null; if(saveFile.endsWith(".csv
REQ for connection b/w jdbc and oracle database
REQ for connection b/w jdbc and oracle database    REQ for connection b/w jdbc and oracle database    The Java classes to connect... tell the Oracle driver which method you want to use to connect to the database
insert user session into other oracle database table
insert user session into other oracle database table   hello i am a doing my project in jsp-servlet. i have doubt that when a user login to his... table. with user id i also want to insert date and current time in to database
Export Database table to CSV File
Export Database table to CSV File In this tutorial, you will learn how to retrieve data from database and save it to CSV File. The Comma-separated values... as writing into a CSV file. Here is a database table is to be extracted:ADS
How to connect to database to my application if the database is made up in oracle
) Connect to database:***ADS_TO_REPLACE_3 a) If you are using oracle oci driver...How to connect to database to my application if the database is made up in oracle  How to connect to database to my application if the database
Dropdown code to retrieve result from oracle database
Dropdown code to retrieve result from oracle database  Hi Friends, I... retrieve the result from Oracle database.We have procedures created already.Just... that will retrieve values from the database into dropdown. As the user choose any option
fetch record from oracle database using jsp-servlet?
fetch record from oracle database using jsp-servlet?  how can i fetch data from oracle database by using jsp-servlet. i'm using eclipse, tomcat server and oracle database and creating jsp pages and also using servlet
how to connection jsp to oracle database connections in netbeans ide
how to connection jsp to oracle database connections in netbeans ide  how to connect jsp to oracle database connections in netbeans ide?pls provide screenshots if possible
how to connection jsp to oracle database connections in netbeans ide
how to connection jsp to oracle database connections in netbeans ide  how to connect jsp to oracle database connections in netbeans ide?pls provide screenshots if possible
if my database(oracle) connection failure means wat is the code to write in exception ?
if my database(oracle) connection failure means wat is the code to write in exception ?  if my database(oracle) connection failure means wat is the code to write in exception
unable to get datas from oracle database
unable to get datas from oracle database  Dear Sir, I am again struck in my project.. i want to display data from oracle database but i get...("jdbc:oracle:thin:@//172.25.50.247:1521/knits", "ADMIN", "ADMIN"); ps

Ads