-2

I need to insert data from excel to database which looks:

Id  Name    Phone   Joining Date  Subject
1   A      11111    14-Mar-2001   Cse
2   B      22222    25-Dec-2016   IT
3   C      33333    12-Dec-2011   ECE

If I have to perform batch insert in a single table then I am able to do it using spring jdbctemplate(batchUpdate(...)).

But I want it to insert data in multiple tables e.g. 1st 3 columns in Table1, next 2 in Table2, next n in table3 like this way.

For reading data I am using POI API and after extracting data m keeping it in List of Map object which looks:

allObj=[{0=1.0, 1=A, 2=11111.0, 3=2001-3-14 0:0:0, 4=Cse}, {0=2.0, 1=B, 2=22222.0, 3=2016-12-25 0:0:0, 4=IT}, {0=3.0, 1=C, 2=33333.0, 3=2011-12-12 0:0:0, 4=ECE}]

How to perform this tasks? not asking full solution but a hint. Thanks

If coding is required then inform I am not posting it as it is lengthy and common.

EDITED: Few didn't understand the Question!

I think u know batch update. I am using JdbcTemplate of spring. suppose I have table T1 as: Id|Name|Phone|Joining Date| Subject in Database(using MYSQL)

Now, I have an excel file with the corresponding values.I can read it and batch insert it into database by JdbcTemplate in that table.

But Now I have two table as T1: Id|Name|Phone and T2: Joining Date| Subject

I have the same excel file. NOW my question comes into the frame. How to insert the values in two tables? If you get the question kindly remove your -ve vote.

Joe
  • 479
  • 3
  • 8
  • 31
  • take a look at this similar [**post**](http://stackoverflow.com/questions/1310166/how-to-import-an-excel-file-in-to-a-mysql-database) – 1000111 Apr 27 '16 at 05:07
  • To be honest I didnt find the similarity. can u indicate it? – Joe Apr 27 '16 at 05:54

1 Answers1

-1
LOAD DATA LOCAL INFILE 
'C:\\temp\\file.csv'
INTO TABLE table_name
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(@col1,@col2)
set
column1 = @col1,
column2 = @col2;

Above query for table1, run same for other tables by changing column_names accordingly.

Priyanshu
  • 885
  • 6
  • 12
  • Actually I am trying to create an app where one can upload an excel file with all the info and data will be inserted into corresponding fields of corresponding tables. I am using java(spring fw) for that. – Joe Apr 27 '16 at 05:49