Home  >  Q&A  >  body text

oracle - Docker中发布java web项目Could not get JDBC Connection

项目是(spring+mybatis+oracle)
docker是安装在虚拟机下面的,jdbc连接的数据库是安装另外一台linux的物理机上面,本机测试能通过,但是到虚拟机里的docker环境下就报这个错误,是什么原因?
报错信息如下:
Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (ORA-00604: 递归 SQL 级别 1 出现错误
ORA-01882: 未找到时区
)

Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (The Network Adapter could not establish the connection)

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
黄舟黄舟2706 days ago844

reply all(2)I'll reply

  • 習慣沉默

    習慣沉默2017-04-26 09:04:21

    If the Docker container needs to connect to other hosts, you need to use the "--net=host" option when running, which means that the container and the host share the network.

    sudo docker run --net=host 

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-04-26 09:04:21

    Try to set the virtual machine to NAT network mode. After setting up, the network behavior of the virtual machine is just like the host machine, accessing the external network and the LAN where the host machine is located.

    reply
    0
  • Cancelreply