问题一:
错误信息:
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
解决方法:
“com.mysql.jdbc.Driver”已被弃用。新的驱动程序类是`com.mysql.cj.jdbc.Driver'
问题二:
错误信息:
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.
翻译:服务器时区值'?? u±e×??±??未被识别或代表多个时区。如果希望利用时区支持,必须配置服务器或JDBC驱动程序(通过serverTimezone配置属性),以使用更特殊的时区值。
解决方法:
在数据库Url后面添加“?serverTimezone=GMT”,重启服务器
问题三:
错误信息:
客服端HttpURLConnection以post传中文数据时,服务器request接收中文乱码
解决方法:
在客服端out.writeBytes(string); 改成 out.write(string.getBytes());
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
out.write(request.getJsonStr().getBytes());
//out.writeBytes(request.getJsonStr());//中文乱码罪魁祸首
out.flush();
原因:
因为java里的char类型是16位的,一个char可以存储一个中文字符,在将其转换为 byte后高8位会丢失,这样就无法将中文字符完整的输出到输出流中。所以在可能有中文字符输出的地方最好先将其转换为字节数组,然后再通过write写入流,目前尝试过这种方法:把上面链接代码中的out.writeBytes(content);替换为out.write(content.getBytes());先把数据转成BYTE在写入流,执行成功,服务器接收正确的中文内容
解决方法来源: