mysql查表的时候报错:java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timest
在spark项目中读取mysql中的数据的时候,发生了报错:

原因:主要是因为数据库中有一些字段为null,无法进行转换:

上面字段那种,我的inserttime字段类型为timestamp类型,不为空,默认值为000-00-00 00:00:00,所以无法进行转换,所以要进行处理一下
所以这里要进行一下转换,需要在url中添加一些转换:
修改之前的url:
jdbc:mysql://localhost:3306/test?serverTimezone=UTC
修改之后的url:
jdbc:mysql://localhost:3306/test?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&serverTimezone=UTC

这样就不会报错了,会直接将000-00-00 00:00:00转换为null进行显示
问题解决
mysql查表的时候报错:java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timest的更多相关文章
- mysql单表多timestamp报错#1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
一个表中出现多个timestamp并设置其中一个为current_timestamp的时候经常会遇到#1293 - Incorrect table definition; there can be o ...
- python2 + selenium + eclipse 中,通过django生产数据库表的时候报错
python2 + selenium + eclipse 中,通过django生产数据库表的时候报错 解决: 1.查看自己电脑中,“开始-->控制面板-->管理工具-->服务--&g ...
- 在给mysql数据库备份时,报错: mysqldump: Got error: 145: Table '.\shengdaxcom\pre_forum_thread' is marked as c rashed and should be repaired when using LOCK TABLES
在给mysql数据库备份时,报错: mysqldump: Got error: 145: Table '.\shengdaxcom\pre_forum_thread' is marked as cra ...
- hibernate有关联关系删除子表时可能会报错,可以用个clear避免错误
//清除子表数据 public SalesSet removeSalesSetDistributor(SalesSet salesSet ){ List<SalesSetDistributor& ...
- sql server 2008 创建新数据库报错、创建表报错、更改表的设计报错
一:创建数据库报错如下: 二:解决,将软件以管理员身份运行 三:创建表报错如下图: 四:解决办法,在你创建的数据库下面的安全里,找到你创建的用户,属性,添加权限,红色标注,然后确定: 五:更改表的设计 ...
- log4j的1.2.15版本,在pom.xml中的顶层project报错错误: Failure to transfer javax.jms:jms:jar:1.1 from https://maven-repository.dev.java.net/nonav/repository......
在动态网站工程中,添加了Pom依赖,当添加log4j的1.2.15版本依赖时,在pom.xml中的顶层project报错错误: Failure to transfer javax.jms:jms:ja ...
- egg 连接 mysql 的 docker 容器,报错:Client does not support authentication protocol requested by server; consider upgrading MySQL client
egg 连接 mysql 的 docker 容器,报错:Client does not support authentication protocol requested by server; con ...
- vue 表单校验报错 "Error: please transfer a valid prop path to form item!"
vue 表单校验报错 "Error: please transfer a valid prop path to form item!" 原因:prop的内容和rules中定义的名称 ...
- java 执行mysql 8.0.11存储过程报错The user specified as a definer ('root'@'10.%.%.%') does not exist解决办法
执行存储过程,报错 java.sql.SQLException: The user specified as a definer ('root'@'10.%.%.%') does not exist ...
随机推荐
- winrar目录穿越漏洞
地址: 参考: https://research.checkpoint.com/extracting-code-execution-from-winrar/ POC: https://github.c ...
- ubuntu16.04下g++安装及使用
1)首先在虚拟机中安装Ubuntu16.04,网络模式设置为NAT模式,安装完成后在虚拟机中测试是否能够上网. 2)进入Ubuntu,按Ctrl+alt+T,调出终端,输入sudo su,输入密码切换 ...
- zookeeper注册与发现
pom.xml添加如下引用: <dependency> <groupId>org.apache.zookeeper</groupId> <artifactId ...
- SQL中sysname数据类型的含义(转)
sysname SQL Server 实例包括用户定义的名为 sysname 的数据类型.sysname 用于表列.变量以及用于存储对象名的存储过程参数.sysname 的精确定义与标识符规则相关:因 ...
- Haproxy + Keepalived +PXC 常见错误
1. Apr 21 19:15:54 pxc1 systemd[1]: mysql@bootstrap.service: main process exited, code=exited, statu ...
- 20180519001 - DataTable Group by功能参考
DataSet6 = DataSet1.Copy(); DataRow[] dr = DataSet6.Tables[0].Select(" 完工状态 = '完工异常' "); D ...
- JS中if判断 非空即为真 非0即为真
1.字符串参与判断时:非空即为真判断字符串为空的方法if(str!=null && str!=undefined && str !='')可简写为if(!str){ ...
- vue 3.0的搭建
1. 删除以前的vue 2.x版本,并下载3.x版本 npm uninstall -g vue-cli / yarn global remove vue-cli npm install -g @vue ...
- 安装LNMP笔记
安装好centos7,主机ssl连不上 网卡设置为桥接模式或NAT模式 防火墙的原因 首先telnet本机22口 先更新yum源 yum update -y 安装网络常用工具:telnet trace ...
- Overture小课堂之如何演绎钢琴滑音
在我们学习钢琴和学习使用Overture时,要学习如何弹奏和使用滑音.那么我们先来看看什么是滑音,如何使用钢琴演绎,在Overture里滑音又在哪里呢? 滑音,在音乐术语中通常指一种装饰音和演奏指法. ...