servlet和JSP学习指南案例app10d

新建web项目,把案例代码直接移过来,然后配置好mysql数据库(不懂的自行百度),本文主要介绍版本兼容以及数据库连接问题。

首先,JDNI数据库连接:参考博客https://blog.csdn.net/u012572955/article/details/52367067,主要修改为:

1.修改server.xml 文件

[html] view plain copy

  1. <Resource name="jdbc/mydata"  
  2. auth="Container"  
  3. type="javax.sql.DataSource"  
  4. maxActive="100"  
  5. maxIdle="30"  
  6. maxWait="10000"  
  7. username="root"     
  8. password="root"  
  9. driverClassName="com.mysql.jdbc.Driver"  
  10. url="jdbc:mysql://localhost:8080/mydata"/> 

2.在web.xml 文件之中完成配置

扫描二维码关注公众号,回复: 5343610 查看本文章

<resource-ref>

    <res-ref-name>jdbc/mydata</res-ref-name>

    <res-type>javax.sql.DataSource</res-type>

   <res-auth>Container</res-auth>

</resource-ref>

配置暂时完成,运行代码,打开页面输入数据保存的时候应该会报The server time zone value '???ú±ê×??±??' is ............. 的错误,解决方法:

https://blog.csdn.net/weixin_37577564/article/details/80329775

URL="jdbc:mysql://localhost:3306/jdbc01?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false";//链接的mysql

直接把这个url的内容复制到server.xml中,然后xml报错了,无法启动,错误的原因呢就是特殊符号 &;而且就报错来说呢,我们不需要这么多东西,只需要把 ?serverTimezone=GMT%2B8 复制到刚才server.xml后面就可以解决上面的问题。

继续运行,保存继续出错(closing inbound before receiving peer's close_notify,图在下面,这个错误就算不解决程序也能跑的,只是会有报错而已),解决方法:

在url后面加个条件 useSSL=false 又遇到了刚才的特殊符号问题,

url="jdbc:mysql://192.168.1.144:3306/leadtest?useUnicode=true&amp;characterEncoding=utf-8";

看到案例得知 & ==》 &amp;   即可以实现多条件限制,所以最后的url:

url="jdbc:mysql://localhost:3306/test?serverTimezone=GMT%2B8&amp;useSSL=false"

再次运行,程序正常,无任何报错。

** BEGIN NESTED EXCEPTION ** 

javax.net.ssl.SSLException
MESSAGE: closing inbound before receiving peer's close_notify

猜你喜欢

转载自blog.csdn.net/u012919352/article/details/84846093