hikari oracle连接失败(春季启动)

时间:2020-10-28 19:32:46

标签: java oracle spring-boot hikaricp

我正在尝试使用Hikari连接我的Oracle数据库, 但出于某种原因HikariDataSource ds = new HikariDataSource(dbConfig);行 提示我错误

2020-10-29 00:06:51.496 [restartedMain] INFO  com.zaxxer.hikari.HikariDataSource.<init>(80) - HikariPool-1 - Starting...
2020-10-29 00:06:52.608 [restartedMain] ERROR com.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException(593) - HikariPool-1 - Exception during pool initialization.
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:458)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:236)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
 HikariConfig dbConfig = new HikariConfig();
        dbConfig.setJdbcUrl("jdbc:oracle:thin:@ip:1521/tabs1");
        dbConfig.setUsername("usernmae");
        dbConfig.setPassword("password");
        dbConfig.setDriverClassName("oracle.jdbc.OracleDriver");
        dbConfig.setMinimumIdle(1);
        dbConfig.setMaximumPoolSize(3);
        dbConfig.setAutoCommit(false);
        log.info("Configs are :" +dbConfig);
        HikariDataSource ds = new HikariDataSource(dbConfig);

我已经对其进行了大量研究,但无法找到解决方案的确切问题。

1 个答案:

答案 0 :(得分:0)

请使用以下其中一项

 jdbc:oracle:thin:@HOST:PORT:SID

jdbc:oracle:thin:@//HOST:PORT/SERVICE

据我所知,您错过了前两个反斜杠,并最终在Connect中尝试使用SID,而服务名未被识别。