錯誤:
Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communications link failure
Last packet sent to the server was 0 ms ago.)
解決方法:1、注意驅動包是否正確 驅動類的名字:oracle.jdbc.driver.OracleDriver
2、JDBC URL:jdbc:oracle:thin:@dbip:port:databasename
dbip –為數據庫服務器的IP地址,如果是本地可寫:localhost或127.0.0.1。
port –為數據庫的監聽端口,需要看安裝時的配置,缺省為1521。
databasename –為數據庫的SID,通常為全局數據庫的名字。
舉例如果要訪問本地的數據庫aaaa,端口1521,那么URL寫法如下:
jdbc:oracle:thin:@localhost:1521:aaaa
3、username和password 在properties文件中和xml文件中一定要對應上