0

I have spring-boot app woth application-properties:

spring.jpa.database=postgresql
spring.jpa.show-sql=true

server.port=${PORT:8080}

spring.datasource.driverClassName=org.postgresql.Driver
spring.sql.init.platform=postgres
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.datasource.url=jdbc:postgresql://1**.1**.**.**6:****/dbname  # server address
spring.datasource.username=n******
spring.datasource.password=p********
spring.jpa.hibernate.ddl-auto=update

and in my local computer i use:

scp -P 1111 D:\user-home\test-0.0.1-SNAPSHOT.jar [email protected]:/home/user

and then of course

java -jar test-0.0.1-SNAPSHOT.jar

and I have

org.postgresql.util.PSQLException: The connection attempt failed.
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:315) ~[postgresql-42.2.22.jar!/:42.2.22]
        at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51) ~[postgresql-42.2.22.jar!/:42.2.22]
        at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:223) ~[postgresql-42.2.22.jar!/:42.2.22]
        at org.postgresql.Driver.makeConnection(Driver.java:465) ~[postgresql-42.2.22.jar!/:42.2.22]
        at org.postgresql.Driver.connect(Driver.java:264) ~[postgresql-42.2.22.jar!/:42.2.22]
        at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-4.0.3.jar!/:na]
        at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364) ~[HikariCP-4.0.3.jar!/:na]
        at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206) ~[HikariCP-4.0.3.jar!/:na]
        at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476) ~[HikariCP-4.0.3.jar!/:na]
        at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) ~[HikariCP-4.0.3.jar!/:na]
        at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) ~[HikariCP-4.0.3.jar!/:na]
        at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[HikariCP-4.0.3.jar!/:na]
        at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) ~[hibernate-core-5.4.32.Final.jar!/:5.4.32.Final]
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180) ~[hibernate-core-5.4.32.Final.jar!/:5.4.32.Final]

My postres in pom:

<dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.2.22</version>
        </dependency>

PASTEBIN Here is full console view with error. None of the solutions found work. Does anyone have a solution for this problem?

1 Answer 1

1

It looks like whichever server you are running the jar from is not able to access the database server on that port. You should check to make sure that the firewall on both sides is configured correctly (JAR server allows traffic out on the database port and the database server allows traffic in on the database port from the JAR server's IP address).

You can test the connectivity using telnet by running the command telnet <database-ip> <port> e.g. telnet 123.123.123.123 9876 from the JAR server (assuming telnet is available). If it is able to establish a connection, then running the JAR should be able to run again and connect to the database.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.