load data query is not working with INSERT/REPLACE option
up vote
0
down vote
favorite
I am trying to upload data from CSV file into a mysql database table but i am getting error "java.sql.SQLException: Invalid utf8 character string: '' " when using INSERT/REPLACE option in load data query. but the same query works fine without INSERT/REPLACE option.
Query:
Statement stmt = conn.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String query = "LOAD DATA INFILE 'D:\"+flnm+"' REPLACE INTO TABLE prfl_hntr "
+ "FIELDS TERMINATED by ',' LINES TERMINATED BY 'n' IGNORE 1 LINES"
+ " (candidate, phone, mailid, skill, texp, rexp, pctc,np);";
stmt.executeUpdate(query);
I have verified the syntax in mysql documentation- https://dev.mysql.com/doc/refman/8.0/en/load-data.html.
Please note that i need to use REPLACE/IGNORE option in the query to eliminate duplicate entries.
java mysql load-data-infile
add a comment |
up vote
0
down vote
favorite
I am trying to upload data from CSV file into a mysql database table but i am getting error "java.sql.SQLException: Invalid utf8 character string: '' " when using INSERT/REPLACE option in load data query. but the same query works fine without INSERT/REPLACE option.
Query:
Statement stmt = conn.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String query = "LOAD DATA INFILE 'D:\"+flnm+"' REPLACE INTO TABLE prfl_hntr "
+ "FIELDS TERMINATED by ',' LINES TERMINATED BY 'n' IGNORE 1 LINES"
+ " (candidate, phone, mailid, skill, texp, rexp, pctc,np);";
stmt.executeUpdate(query);
I have verified the syntax in mysql documentation- https://dev.mysql.com/doc/refman/8.0/en/load-data.html.
Please note that i need to use REPLACE/IGNORE option in the query to eliminate duplicate entries.
java mysql load-data-infile
LOAD DATA LOCAL INFILE '/home/xxxxx/conf.csv' INTO TABLE configuration FIELDS TERMINATED BY ',' LINES TERMINATED BY 'n' IGNORE 1 ROWS;
– sk hussain
Nov 21 at 11:26
and also check csv file permissions.
– sk hussain
Nov 21 at 11:28
1
Possible duplicate of Using "LOAD DATA LOCAL INFILE" in Java
– sk hussain
Nov 21 at 11:33
Hi hussain there was a typo in question. The problem is occuring when i am issuing command with REPLACE option. The query works fine without REPLACE option as suggested in the post in the link.
– pmgowda
Nov 21 at 11:49
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to upload data from CSV file into a mysql database table but i am getting error "java.sql.SQLException: Invalid utf8 character string: '' " when using INSERT/REPLACE option in load data query. but the same query works fine without INSERT/REPLACE option.
Query:
Statement stmt = conn.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String query = "LOAD DATA INFILE 'D:\"+flnm+"' REPLACE INTO TABLE prfl_hntr "
+ "FIELDS TERMINATED by ',' LINES TERMINATED BY 'n' IGNORE 1 LINES"
+ " (candidate, phone, mailid, skill, texp, rexp, pctc,np);";
stmt.executeUpdate(query);
I have verified the syntax in mysql documentation- https://dev.mysql.com/doc/refman/8.0/en/load-data.html.
Please note that i need to use REPLACE/IGNORE option in the query to eliminate duplicate entries.
java mysql load-data-infile
I am trying to upload data from CSV file into a mysql database table but i am getting error "java.sql.SQLException: Invalid utf8 character string: '' " when using INSERT/REPLACE option in load data query. but the same query works fine without INSERT/REPLACE option.
Query:
Statement stmt = conn.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String query = "LOAD DATA INFILE 'D:\"+flnm+"' REPLACE INTO TABLE prfl_hntr "
+ "FIELDS TERMINATED by ',' LINES TERMINATED BY 'n' IGNORE 1 LINES"
+ " (candidate, phone, mailid, skill, texp, rexp, pctc,np);";
stmt.executeUpdate(query);
I have verified the syntax in mysql documentation- https://dev.mysql.com/doc/refman/8.0/en/load-data.html.
Please note that i need to use REPLACE/IGNORE option in the query to eliminate duplicate entries.
java mysql load-data-infile
java mysql load-data-infile
edited yesterday
asked Nov 21 at 11:17
pmgowda
135
135
LOAD DATA LOCAL INFILE '/home/xxxxx/conf.csv' INTO TABLE configuration FIELDS TERMINATED BY ',' LINES TERMINATED BY 'n' IGNORE 1 ROWS;
– sk hussain
Nov 21 at 11:26
and also check csv file permissions.
– sk hussain
Nov 21 at 11:28
1
Possible duplicate of Using "LOAD DATA LOCAL INFILE" in Java
– sk hussain
Nov 21 at 11:33
Hi hussain there was a typo in question. The problem is occuring when i am issuing command with REPLACE option. The query works fine without REPLACE option as suggested in the post in the link.
– pmgowda
Nov 21 at 11:49
add a comment |
LOAD DATA LOCAL INFILE '/home/xxxxx/conf.csv' INTO TABLE configuration FIELDS TERMINATED BY ',' LINES TERMINATED BY 'n' IGNORE 1 ROWS;
– sk hussain
Nov 21 at 11:26
and also check csv file permissions.
– sk hussain
Nov 21 at 11:28
1
Possible duplicate of Using "LOAD DATA LOCAL INFILE" in Java
– sk hussain
Nov 21 at 11:33
Hi hussain there was a typo in question. The problem is occuring when i am issuing command with REPLACE option. The query works fine without REPLACE option as suggested in the post in the link.
– pmgowda
Nov 21 at 11:49
LOAD DATA LOCAL INFILE '/home/xxxxx/conf.csv' INTO TABLE configuration FIELDS TERMINATED BY ',' LINES TERMINATED BY 'n' IGNORE 1 ROWS;
– sk hussain
Nov 21 at 11:26
LOAD DATA LOCAL INFILE '/home/xxxxx/conf.csv' INTO TABLE configuration FIELDS TERMINATED BY ',' LINES TERMINATED BY 'n' IGNORE 1 ROWS;
– sk hussain
Nov 21 at 11:26
and also check csv file permissions.
– sk hussain
Nov 21 at 11:28
and also check csv file permissions.
– sk hussain
Nov 21 at 11:28
1
1
Possible duplicate of Using "LOAD DATA LOCAL INFILE" in Java
– sk hussain
Nov 21 at 11:33
Possible duplicate of Using "LOAD DATA LOCAL INFILE" in Java
– sk hussain
Nov 21 at 11:33
Hi hussain there was a typo in question. The problem is occuring when i am issuing command with REPLACE option. The query works fine without REPLACE option as suggested in the post in the link.
– pmgowda
Nov 21 at 11:49
Hi hussain there was a typo in question. The problem is occuring when i am issuing command with REPLACE option. The query works fine without REPLACE option as suggested in the post in the link.
– pmgowda
Nov 21 at 11:49
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
accepted
You are right the issue is not with the syntax. The issue might be with difference in the characterset between Mysql table and your CSV file. I had a similar problem and resolved it by mentioning the characterset in the query. Try the query given below it should work and make sure your CSV file has data supported by Mysql table.
Query:
String query = "LOAD DATA INFILE 'D:\"+flnm+"' REPLACE INTO TABLE prfl_hntr "
+"character set latin1 "
+ "FIELDS TERMINATED by ',' LINES TERMINATED BY 'n' IGNORE 1 LINES"
+ " (candidate, phone, mailid, skill, texp, rexp, pctc,np);";
stmt.executeUpdate(query);
Further you can follow the answer by @RolandoMySQLDBA for this question-: Trying to do LOAD DATA INFILE with REPLACE and AUTO_INCREMENT
It worked wonders for me.
That works thank you.
– pmgowda
16 hours ago
add a comment |
up vote
0
down vote
LOAD DATA LOCAL INFILE '/home/xxxxx/conf.csv' INTO TABLE configuration FIELDS TERMINATED BY ',' LINES TERMINATED BY 'n' IGNORE 1 ROWS;
try this once.
Hi hussain, Please take into account that i need to use either IGNORE or REPLACE option because am trying to avoid duplicates when loading data. Also please note that this question is not a duplicate because this issue is not addressed in other post.
– pmgowda
Nov 21 at 11:52
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
You are right the issue is not with the syntax. The issue might be with difference in the characterset between Mysql table and your CSV file. I had a similar problem and resolved it by mentioning the characterset in the query. Try the query given below it should work and make sure your CSV file has data supported by Mysql table.
Query:
String query = "LOAD DATA INFILE 'D:\"+flnm+"' REPLACE INTO TABLE prfl_hntr "
+"character set latin1 "
+ "FIELDS TERMINATED by ',' LINES TERMINATED BY 'n' IGNORE 1 LINES"
+ " (candidate, phone, mailid, skill, texp, rexp, pctc,np);";
stmt.executeUpdate(query);
Further you can follow the answer by @RolandoMySQLDBA for this question-: Trying to do LOAD DATA INFILE with REPLACE and AUTO_INCREMENT
It worked wonders for me.
That works thank you.
– pmgowda
16 hours ago
add a comment |
up vote
0
down vote
accepted
You are right the issue is not with the syntax. The issue might be with difference in the characterset between Mysql table and your CSV file. I had a similar problem and resolved it by mentioning the characterset in the query. Try the query given below it should work and make sure your CSV file has data supported by Mysql table.
Query:
String query = "LOAD DATA INFILE 'D:\"+flnm+"' REPLACE INTO TABLE prfl_hntr "
+"character set latin1 "
+ "FIELDS TERMINATED by ',' LINES TERMINATED BY 'n' IGNORE 1 LINES"
+ " (candidate, phone, mailid, skill, texp, rexp, pctc,np);";
stmt.executeUpdate(query);
Further you can follow the answer by @RolandoMySQLDBA for this question-: Trying to do LOAD DATA INFILE with REPLACE and AUTO_INCREMENT
It worked wonders for me.
That works thank you.
– pmgowda
16 hours ago
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
You are right the issue is not with the syntax. The issue might be with difference in the characterset between Mysql table and your CSV file. I had a similar problem and resolved it by mentioning the characterset in the query. Try the query given below it should work and make sure your CSV file has data supported by Mysql table.
Query:
String query = "LOAD DATA INFILE 'D:\"+flnm+"' REPLACE INTO TABLE prfl_hntr "
+"character set latin1 "
+ "FIELDS TERMINATED by ',' LINES TERMINATED BY 'n' IGNORE 1 LINES"
+ " (candidate, phone, mailid, skill, texp, rexp, pctc,np);";
stmt.executeUpdate(query);
Further you can follow the answer by @RolandoMySQLDBA for this question-: Trying to do LOAD DATA INFILE with REPLACE and AUTO_INCREMENT
It worked wonders for me.
You are right the issue is not with the syntax. The issue might be with difference in the characterset between Mysql table and your CSV file. I had a similar problem and resolved it by mentioning the characterset in the query. Try the query given below it should work and make sure your CSV file has data supported by Mysql table.
Query:
String query = "LOAD DATA INFILE 'D:\"+flnm+"' REPLACE INTO TABLE prfl_hntr "
+"character set latin1 "
+ "FIELDS TERMINATED by ',' LINES TERMINATED BY 'n' IGNORE 1 LINES"
+ " (candidate, phone, mailid, skill, texp, rexp, pctc,np);";
stmt.executeUpdate(query);
Further you can follow the answer by @RolandoMySQLDBA for this question-: Trying to do LOAD DATA INFILE with REPLACE and AUTO_INCREMENT
It worked wonders for me.
answered 18 hours ago
pradyu
667
667
That works thank you.
– pmgowda
16 hours ago
add a comment |
That works thank you.
– pmgowda
16 hours ago
That works thank you.
– pmgowda
16 hours ago
That works thank you.
– pmgowda
16 hours ago
add a comment |
up vote
0
down vote
LOAD DATA LOCAL INFILE '/home/xxxxx/conf.csv' INTO TABLE configuration FIELDS TERMINATED BY ',' LINES TERMINATED BY 'n' IGNORE 1 ROWS;
try this once.
Hi hussain, Please take into account that i need to use either IGNORE or REPLACE option because am trying to avoid duplicates when loading data. Also please note that this question is not a duplicate because this issue is not addressed in other post.
– pmgowda
Nov 21 at 11:52
add a comment |
up vote
0
down vote
LOAD DATA LOCAL INFILE '/home/xxxxx/conf.csv' INTO TABLE configuration FIELDS TERMINATED BY ',' LINES TERMINATED BY 'n' IGNORE 1 ROWS;
try this once.
Hi hussain, Please take into account that i need to use either IGNORE or REPLACE option because am trying to avoid duplicates when loading data. Also please note that this question is not a duplicate because this issue is not addressed in other post.
– pmgowda
Nov 21 at 11:52
add a comment |
up vote
0
down vote
up vote
0
down vote
LOAD DATA LOCAL INFILE '/home/xxxxx/conf.csv' INTO TABLE configuration FIELDS TERMINATED BY ',' LINES TERMINATED BY 'n' IGNORE 1 ROWS;
try this once.
LOAD DATA LOCAL INFILE '/home/xxxxx/conf.csv' INTO TABLE configuration FIELDS TERMINATED BY ',' LINES TERMINATED BY 'n' IGNORE 1 ROWS;
try this once.
answered Nov 21 at 11:27
sk hussain
8810
8810
Hi hussain, Please take into account that i need to use either IGNORE or REPLACE option because am trying to avoid duplicates when loading data. Also please note that this question is not a duplicate because this issue is not addressed in other post.
– pmgowda
Nov 21 at 11:52
add a comment |
Hi hussain, Please take into account that i need to use either IGNORE or REPLACE option because am trying to avoid duplicates when loading data. Also please note that this question is not a duplicate because this issue is not addressed in other post.
– pmgowda
Nov 21 at 11:52
Hi hussain, Please take into account that i need to use either IGNORE or REPLACE option because am trying to avoid duplicates when loading data. Also please note that this question is not a duplicate because this issue is not addressed in other post.
– pmgowda
Nov 21 at 11:52
Hi hussain, Please take into account that i need to use either IGNORE or REPLACE option because am trying to avoid duplicates when loading data. Also please note that this question is not a duplicate because this issue is not addressed in other post.
– pmgowda
Nov 21 at 11:52
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410959%2fload-data-query-is-not-working-with-insert-replace-option%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
LOAD DATA LOCAL INFILE '/home/xxxxx/conf.csv' INTO TABLE configuration FIELDS TERMINATED BY ',' LINES TERMINATED BY 'n' IGNORE 1 ROWS;
– sk hussain
Nov 21 at 11:26
and also check csv file permissions.
– sk hussain
Nov 21 at 11:28
1
Possible duplicate of Using "LOAD DATA LOCAL INFILE" in Java
– sk hussain
Nov 21 at 11:33
Hi hussain there was a typo in question. The problem is occuring when i am issuing command with REPLACE option. The query works fine without REPLACE option as suggested in the post in the link.
– pmgowda
Nov 21 at 11:49