Monika Galińska
Monika Galińska

Reputation: 201

Spring Boot application The url cannot be null

Hello when i trying start Spring Boot app a get a stacktrace

2016-11-18 04:41:35.492  WARN 4256 --- [  restartedMain] o.a.tomcat.jdbc.pool.PooledConnection    : Not loading a JDBC driver as driverClassName property is null.
2016-11-18 04:41:35.499 ERROR 4256 --- [  restartedMain] o.a.tomcat.jdbc.pool.ConnectionPool      : Unable to create initial connections of pool.

java.sql.SQLException: The url cannot be null
    at java.sql.DriverManager.getConnection(DriverManager.java:649) ~[na:1.8.0_111]
    at java.sql.DriverManager.getConnection(DriverManager.java:208) ~[na:1.8.0_111]
    at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:308) ~[tomcat-jdbc-8.5.4.jar:na]
    at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203) ~[tomcat-jdbc-8.5.4.jar:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:716) [tomcat-jdbc-8.5.4.jar:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:648) [tomcat-jdbc-8.5.4.jar:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:468) [tomcat-jdbc-8.5.4.jar:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:143) [tomcat-jdbc-8.5.4.jar:na]
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118) [tomcat-jdbc-8.5.4.jar:na]
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:107) [tomcat-jdbc-8.5.4.jar:na]

I added url in application.properties

spring.datasource.url=jdbc:oracle:thin:@localhost:1521:spring

I think it's may be problem with drivers to oracle, maven can't find this dependency

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc14</artifactId>
    <version>10.2.0.4.0</version>
</dependency>

So I just add external jar to my project, but i still have problem with wrong url

Upvotes: 2

Views: 12500

Answers (2)

Sergio.Gaspar
Sergio.Gaspar

Reputation: 66

The Oracle JDBC driver has only been a part of maven from V 11.2.0.4.. had some issues with it in the past.

Follow the link "https://blogs.oracle.com/dev2dev/entry/oracle_maven_repository_instructions_for" to download and add the driver you want to the local maven repo.

Also check Find Oracle JDBC driver in Maven repository

Please make sure you have specified and included the relevant database vendor dependency in your pom. If not, you might also experience the same error message.

Upvotes: 0

mixiul__
mixiul__

Reputation: 395

Not loading a JDBC driver as driverClassName property is null.

You might also want to resolve that by adding a driver class name to your properties file:

spring.datasource.driver-class-name=oracle.jdbc.OracleDriver

Are you configuring a DataSource bean somewhere within your application? Assuming you haven't disabled auto configuration you should be able to get a valid datasource configuration.

Upvotes: 3

Related Questions