计划
我希望我的tomcat服务器能够在单独的容器中连接到我的MySQL服务器.
问题
Tomcat无法连接到MysqL
我使用了wordpress tutorial中有关设置MysqL容器链接的一些细节,并创建了MysqL的链接.
虽然tomcat和MysqL旋转得很好我似乎无法让tomcat能够连接到MysqL,我的本地机器上的设置工作完全没问题.
我试图使用–net:“host”,尽管这不适用于Tomcat,因为它会引发严重的错误.
以前的答案
我可以修复错误的noticed on this post a load虽然我不相信其中任何一个会转换为我的问题,因为我认为这是一个码头工人问题而不是主机问题.
泊坞窗,compose.yml
web:
image: tomcat:7.0
container_name: tomcat-container
ports:
- "80:8080"
hostname: docker-tomcat
volumes:
- /home/webapps:/usr/local/tomcat/webapps
links:
- db
db:
image: MysqL
container_name: MysqL-container
environment:
MysqL_ROOT_PASSWORD: MysqLpassword1
MysqL_DATABASE: tracker
volumes:
- /home/MysqLDB:/var/lib/MysqL
这是我在tomcat中的Context.xml.
sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
url="jdbc:MysqL://localhost:3306/tracker?useSSL=false"
driverClassName="com.MysqL.jdbc.Driver"
username="root" password="MysqLadmin1"
/>
sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
url="jdbc:MysqL://localhost:3306/jenkins?useSSL=false"
driverClassName="com.MysqL.jdbc.Driver"
username="root" password="MysqLadmin1"
/>
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at databaseConnections.sqlDatabaseConnection.tableExists(sqlDatabaseConnection.java:131)
at databaseConnections.JirasqlDatabaseConnection.sqlDatabaseConnection.java:50)
最佳答案