您的位置:首頁技術文章
文章詳情頁

oracle - Docker中發布java web項目Could not get JDBC Connection

瀏覽:136日期:2024-03-22 10:12:31

問題描述

項目是(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)

問題解答

回答1:

Docker容器如果需要鏈接其他主機的話,運行時需要使用'--net=host'選項,表示容器與主機共享網絡。

sudo docker run --net=host 回答2:

試著將虛擬機設置NAT網絡模式。設置好之后虛擬機的網絡行為就像宿主機一樣,訪問外網和宿主機所在的局域網。

標簽: java
相關文章:
国产综合久久一区二区三区