I try deploy my application on Heroku, but have some errors which I can't fix my application.poperties
spring.mvc.view.prefix = /WEB-INF/view/
spring.mvc.view.suffix = .jsp
spring.datasource.url = jdbc:postgres://user:[email protected]:5432/database
# Username and password
spring.datasource.username = user
spring.datasource.password = pass
# Keep the connection alive if idle for a long time (needed in production)
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
spring.datasource.driverClassName=org.postgresql.Driver
# ===============================
# = JPA / HIBERNATE
# ===============================
# Use spring.jpa.properties.* for Hibernate native properties (the prefix is
# stripped before adding them to the entity manager).
# Show or not log for each sql query
spring.jpa.show-sql = true
# Hibernate ddl auto (create, create-drop, update): with "update" the database
# schema will be automatically updated accordingly to java entities found in
# the project
spring.jpa.hibernate.ddl-auto = update
# Naming strategy
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
my Application class is standart spring boot class for application starting
my pom.xml (part of it):
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
</dependencies>
<build>
<finalName>spring</finalName>
<plugins>
<!-- Spring Boot Maven -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.github.jsimone</groupId>
<artifactId>webapp-runner</artifactId>
<version>8.0.30.2</version>
<destFileName>webapp-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Error which I receive
> 12:06:42.061 INFO 12352 --- [ost-startStop-1]
> o.s.b.w.servlet.FilterRegistrationBean : Mapping filter:
> 'applicationContextIdFilter' to: [/*] 2017-03-10 12:06:42.488 ERROR
> 12352 --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool :
> Unable to create initial connections of pool.
>
> java.sql.SQLException: Driver:org.postgresql.Driver@760cf594 returned
> null for
> URL:jdbc:postgres://fqwebtafwgsgmp:17ff02102b2660162ce1b053ef28340dfa7cf4d71e14b4bf1b187a8ad7d36579@ec2-54-247-166-129.eu-west-1.compute.amazonaws.com:5432/daapseha11ekml
> at
> org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:329)
> ~[tomcat-jdbc-8.5.11.jar:na] at
> org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203)
> ~[tomcat-jdbc-8.5.11.jar:na] at
> org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:732)
> [tomcat-jdbc-8.5.11.jar:na] at
> org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:664)
> [tomcat-jdbc-8.5.11.jar:na] at
> org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:479)
> [tomcat-jdbc-8.5.11.jar:na] at
> org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154)
> [tomcat-jdbc-8.5.11.jar:na] at
> org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118)
> [tomcat-jdbc-8.5.11.jar:na] at
I would be grateful if somebody explain my mistake
You are using jdbc:postgres
in your JDBC URL instead of jdbc:postgresql
(note the extra ql
).
Heroku already sets SPRING_DATASOURCE_URL
environment variable for you, so you should be able to remove your spring.datasource
entries in application.properties
entirely.
If you are not able to remove them, try:
spring.datasource.url=${JDBC_DATABASE_URL}
If that doesn't work, it must mean you are not using the Java buildpack or something.
Also be sure to run:
heroku pg:credentials --reset
Your problem is probably your connection url. You have the valid username and password in the url.
Change your spring.datasource
settings to:
spring.datasource.url = jdbc:postgres://ec2-54-247-166-129.eu-west-1.compute.amazonaws.com:5432/database
# Username and password
spring.datasource.username = user
spring.datasource.password = pass
PS. I tried and connected to your db instance so I would change them ASAP.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With