Posts

Showing posts from July, 2016

Struts 1 with JSON response

You want to explore struts 1.X with ajax based application which returns JSON as a response, you can go following public repository.

https://github.com/youdhveer/struts1

Load csv file data into MySQL table

Suppose we have a device table along with following columns.
id(integer),device(varchar),device_data(varchar).

Now suppose you want to upload data from a device.csv file like given below.
---------------------------------------------------
"id","device","device_data"
"1","A1","this is test device, model-11"
"2","A2","this is test device, model-12"
"3","A3","this is test device, model-13"
"4","A4","this is test device, model-14"
----------------------------------------------------

Use following command to insert these values from csv file to table with casting id value from text to integer.


LOAD DATA INFILE 'D:\device.csv' INTO TABLE device 
FIELDS TERMINATED BY  ',' 
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES
(@id, device, device_data)
SET id= CONVERT( @id, UNSIGNED INTEGER ) ;