Support Questions

Find answers, ask questions, and share your expertise

Sqoop error while import from MySQL: SQLException in nextKeyValue

avatar
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

avatar
Master Guru

@simran kaur - can you please try below jdbc url

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

View solution in original post

7 REPLIES 7

avatar
Master Guru

@simran kaur - can you please try below jdbc url

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

avatar
Expert Contributor

Awesome 🙂 worked like a charm. Thanks

avatar
Contributor

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

avatar
Master Guru

@indrajeet gour

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

avatar
Contributor

Can you please let me know where to try this?

avatar
Super Guru

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

avatar
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.