Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
I am learning SpringBoot and I just tried running my project which used to run successfully, but now this error pops up
enter cod2018-08-25 11:30:21 WARN c.z.hikari.util.DriverDataSource - Registered driver with driverClassName=oracle.jdbc.driver.OracleDriver was not found, trying direct instantiation.
2018-08-25 11:30:24 ERROR com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Exception during pool initialization.
java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connectione here
after this couple of exceptions are thrown like..
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[na:1.8.0_144]
Caused by: java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:673) ~[ojdbc7-12.1.0.2.jar:12.1.0.1.0]
application.properties:
#server
server.port=7003
#database
spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin:@localhost:1521:Xe
spring.datasource.username=XXXXXX
spring.datasource.password=XXXXXX
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
#logging
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n
logging.level.org.hibernate.SQL=INFO
logging.level.org.hibernate.type.descriptor.sql=trace
logging.level.=INFO
#eureka-guidelines
eureka.client.register-with-eureka=true
eureka.client.serviceUrl.defaultZone=http://localhost:7005/eureka
spring.application.name=SupplyManagement_14_SpringBoot
Pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myapp.supplyManagement</groupId>
<artifactId>SupplyManagement_14_SpringBoot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>SupplyManagement_14_SpringBoot</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.2</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I tried some debugging, like
1. manually checking oracle.jdbc.driver.OracleDriver is there or not.
2. using other ojdbc's like 6.
3. maven updates.
But nothing seems to work. Any help is appreciated.
UPDATE
I have no Idea why, But I restarted my System and now it works fine.
Registered driver with driverClassName=oracle.jdbc.driver.OracleDriver was not found, trying direct instantiation
That is because you used the wrong value for spring.datasource.driver-class-name
.
Use oracle.jdbc.OracleDriver
instead of oracle.jdbc.driver.OracleDriver
.
See detailed answer here: Difference between Oracle jdbc driver classes?.
It clearly indicates driver is missing, please check maven local repository, look for jdbc driver jar file in XX:\user\XXX\m2\XX
From oracle web site to connect with Oracle 12 using JDK 8 you can follow this..
<groupid>com.oracle.jdbc</groupid>
<artifactid>ojdbc8</artifactid>
<version>12.2.0.1</version>
–
I think this dependency to get the Oracle JDBC driver was not found on Maven repository.
So, better review POM for this dependency. FYI, the oracle doesn't post the latest JDBC driver in Maven repository. If you wish to get the latest JDBC driver from the Oracle database installation folder (${ORACLE_INSTALLATION}/jdbc) or download it from Oracle Technology Network website. You may refer to this link if you are using 12c version:
https://www.oracle.com/technetwork/database/features/jdbc/jdbc-ucp-122-3110062.html
Then, you need to create new folder to locate your Oracle JDBC driver inside your project and change the dependency for Oracle JDBC by pointing it into the folder you just create.
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.