我有架构
的数据框架id : long (nullable = false)
DDate: timestamp (nullable = true)
EDate: timestamp (nullable = true)
B1Date: timestamp (nullable = true)
B2Date: timestamp (nullable = true)
B3Date: timestamp (nullable = true)
当我使用df.write.jdbc(url," DF",prop)我收到错误
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Invalid default value for 'DDate'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorI mpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorA ccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
对于每个时间戳我都遇到同样的问题如何解决问题
答案 0 :(得分:0)
将timestamp type
更改为java.sql.Timestamp
ex:case class DfWithTs (ts: sent_at: java.sql.Timestamp, value: Int)
val ds = df.as[DfWithTs]
然后编写它,这将与jdbc