Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Sqoop error while import from MySQL: SQLException in nextKeyValue

Solved Go to solution

Sqoop error while import from MySQL: SQLException in nextKeyValue

Expert Contributor

How to fix this error?

va.io.IOException: SQLException in nextKeyValue

	at org.apache.sqoop.mapreduce.db.DBRecordReader.nextKeyValue(DBRecordReader.java:277)
	at org.apache.hadoop.mapred.MapTask$NewTrackingRecordReader.nextKeyValue(MapTask.java:556)
	at org.apache.hadoop.mapreduce.task.MapContextImpl.nextKeyValue(MapContextImpl.java:80)
	at org.apache.hadoop.mapreduce.lib.map.WrappedMapper$Context.nextKeyValue(WrappedMapper.java:91)
	at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:145)
	at org.apache.sqoop.mapreduce.AutoProgressMapper.run(AutoProgressMapper.java:64)
	at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:787)
	at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
	at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:168)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:422)
	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1657)
	at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:162)
Caused by: java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:896)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:885)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
	at com.mysql.jdbc.ResultSetRow.getDateFast(ResultSetRow.java:145)
	at com.mysql.jdbc.ByteArrayRow.getDateFast(ByteArrayRow.java:243)
	at com.mysql.jdbc.ResultSetImpl.getDate(ResultSetImpl.java:2015)
	at com.mysql.jdbc.ResultSetImpl.getDate(ResultSetImpl.java:1978)
	at org.apache.sqoop.lib.JdbcWritableBridge.readDate(JdbcWritableBridge.java:115)
	at com.cloudera.sqoop.lib.JdbcWritableBridge.readDate(JdbcWritableBridge.java:87)
	at additional_input_invoice.readFields(additional_input_invoice.java:325)
	at org.apache.sqoop.mapreduce.db.DBRecordReader.nextKeyValue(DBRecordReader.java:244)
	... 12 more
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Sqoop error while import from MySQL: SQLException in nextKeyValue

Super Guru

@simran kaur - can you please try below jdbc url

jdbc:mysql://yourserver:3306/yourdatabase?zeroDateTimeBehavior=convertToNull
7 REPLIES 7

Re: Sqoop error while import from MySQL: SQLException in nextKeyValue

Super Guru

@simran kaur - can you please try below jdbc url

jdbc:mysql://yourserver:3306/yourdatabase?zeroDateTimeBehavior=convertToNull

Re: Sqoop error while import from MySQL: SQLException in nextKeyValue

Expert Contributor

Awesome :) worked like a charm. Thanks

Re: Sqoop error while import from MySQL: SQLException in nextKeyValue

New Contributor

@Kuldeep Kulkarni what about if the same error happen for Oracle?

Re: Sqoop error while import from MySQL: SQLException in nextKeyValue

Super Guru

@indrajeet gour

Can you please post a separate question along with detailed stack trace?

Re: Sqoop error while import from MySQL: SQLException in nextKeyValue

New Contributor

Can you please let me know where to try this?

Re: Sqoop error while import from MySQL: SQLException in nextKeyValue

Append this to your jdbc connection string "?zeroDateTimeBehavior=convertToNull&autoReconnect=true&characterEncoding=UTF-8&characterSetResults=UTF-8"

in MySQL '0000-00-00' represent a valid date but it can not represented in java.sql.Date

Re: Sqoop error while import from MySQL: SQLException in nextKeyValue

New Contributor

I'm not sure if you are using 'split-by' option.

In my case, this error happened because I was using 'split-by' column with a date column for distributing the process into nodes in the cluster, when I retrieve data using a query.

That was corrected when I use an integer column instead of using a date column

It seems that using date or string column is not working properly with sqoop when you use a query.