本文主要是介绍tomcat9+eclipse_oxygen+mysql-connector-java-8.0.11 JNDI配置,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
步骤:
1.mysql-connector-java-8.0.11.jar放到apache-tomcat-9.0.8的lib目录下
2.在eclipse生成的severs目录下配置context.xml文件。增加内容:
<Resource
name="jdbc/yourdbname"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
driverClassName="com.mysql.cj.jdbc.Driver"
url="jdbc:mysql://localhost:3306/yourdbname?characterEncoding=UTF-8&serverTimezone=UTC"
username="root"
password="root"
/>
其中,由于mysql_connector是最新版本,amp;serverTimezone=UTC必须添加上。
3.配置项目下的web.xml文件
<resource-ref>
<description>DBConn</description>
<res-ref-name>jdbc/yourdbname</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
这篇关于tomcat9+eclipse_oxygen+mysql-connector-java-8.0.11 JNDI配置的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!