【问题已解决】黑马旅游网Could not create connection to database server.问题

在黑马旅游网项目中,提交注册表单时,显示Could not create connection to database server.无法创建连接。
【问题已解决】黑马旅游网Could not create connection to database server.问题
解决方案:
第一步:在pom.xml中检查自己的mysql连接驱动与自己环境中的Mysql版本是否一致。
【问题已解决】黑马旅游网Could not create connection to database server.问题
【问题已解决】黑马旅游网Could not create connection to database server.问题
第二步:如果你的mysql驱动版本为8.x,则需要修改druid连接池的配置文件druid.properties。将driverClassName改为com.mysql.cj.jdbc.Driver。
【问题已解决】黑马旅游网Could not create connection to database server.问题
【问题已解决】黑马旅游网Could not create connection to database server.问题
第三步:如果此时提交表单后控制台提示错误:The server time zone value ‘?й???’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the ‘serverTimezone’ configuration property) to use a more specifc time zone value if you want to utilize time zone support.
【问题已解决】黑马旅游网Could not create connection to database server.问题
则需要在druid.properities的url属性后,加上 ?serverTimezone=UTC 如图所示:
【问题已解决】黑马旅游网Could not create connection to database server.问题
从而解决所有错误,成功把表单信息提交到数据库。