Load a csv file in MySql database

LOAD DATA INFILE command is used to load the file's data to the database. 
We have many parameters for firing this query. It differs based on our requirement (Refer MySQL official site to know more).  

Query to Load a CSV ( comma separated values) file into the database:


Example : LOAD DATA INFILE 'C://User//Karthikk//Testing.csv" into TABLE employee FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';

Read more ...

ERROR 1022 (23000)


I came across an error in MySQL when I tried to transfer the data from a remote database to my local database. I was particular about not losing my data by any chance. Hence I manually took back up of the important tables before inserting into my local database. However still to be on a safer side, I renamed the existing table name and imported the exported data from the remote database. While doing so, I surfaced the below mentioned error 

Error Code : ERROR 1022 (23000) at line 27: Can't write; duplicate key in table

Read more ...

How to use Chinese and Japanese character as string in java and store it in MySQL database?


In recent days I had a problem in printing the Japanese / Chinese scripts which are entered by the end user in my application. This issue really bugged me for a week. After so much debugging I fixed the issue.

Actual root cause :

The text encoding failed in terms of handling the conversion of Japanese script to a string and also the Database collation is set to Latin by default in MySQL when I created my schema, which does not accept such scripts to be entered.

Read more ...