Na Aula de conexão com o banco, apartir das alterações feitas o projeto começa a dar erro quando roda (estou usando postgresql ao invés de Mysql)
Segue como o código está:
spring.datasource.url=jdbc:postgresql://localhost/mina?createDatabaseIfNotExist=true
spring.datasource.username=postgres
spring.datasource.password=1404
package com.app.mina.domain.trabalhador;
import jakarta.persistence.*;
@Entity
@Table(name = "trabalhador")
public class Trabalhador {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private String matricula;
private String nome;
private String empresa;
private String rfid;
private String tipo;
private String habilitar;
public Trabalhador(DadosCadastroTrabalhador dados) {
this.matricula = dados.matricula();
this.nome = dados.nome();
this.empresa = dados.empresa();
this.rfid = dados.rfid();
this.tipo = dados.tipo();
this.habilitar = dados.habilitar();
}
@Override
public String toString() {
return "Trabalhador{" +
"matricula='" + matricula + '\'' +
", nome='" + nome + '\'' +
", empresa='" + empresa + '\'' +
", rfid='" + rfid + '\'' +
", tipo='" + tipo + '\'' +
", habilitar='" + habilitar + '\'' +
'}';
}
public String getMatricula() {
return matricula;
}
public String getNome() {
return nome;
}
public String getEmpresa() {
return empresa;
}
public String getRfid() {
return rfid;
}
public String getTipo() {
return tipo;
}
public String getHabilitar() {
return habilitar;
}
}
package com.app.mina.domain.trabalhador;
import org.springframework.data.jpa.repository.JpaRepository;
public interface TrabalhadorRepository extends JpaRepository<Trabalhador, Long> {
}
O erro que aparece é o seguinte:
2023-06-20T11:48:38.063-03:00 INFO 9356 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2023-06-20T11:48:39.114-03:00 ERROR 9356 --- [ restartedMain] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization.
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:342) ~[postgresql-42.6.0.jar:42.6.0]
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:54) ~[postgresql-42.6.0.jar:42.6.0]
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:263) ~[postgresql-42.6.0.jar:42.6.0]
at org.postgresql.Driver.makeConnection(Driver.java:443) ~[postgresql-42.6.0.jar:42.6.0]
at org.postgresql.Driver.connect(Driver.java:297) ~[postgresql-42.6.0.jar:42.6.0]
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-5.0.1.jar:na]
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359) ~[HikariCP-5.0.1.jar:na]
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201) ~[HikariCP-5.0.1.jar:na]
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470) ~[HikariCP-5.0.1.jar:na]
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) ~[HikariCP-5.0.1.jar:na]
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:100) ~[HikariCP-5.0.1.jar:na]
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[HikariCP-5.0.1.jar:na]
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) ~[hibernate-core-6.2.2.Final.jar:6.2.2.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:316) ~[hibernate-core-6.2.2.Final.jar:6.2.2.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:152) ~[hibernate-core-6.2.2.Final.jar:6.2.2.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:34) ~[hibernate-core-6.2.2.Final.jar:6.2.2.Final]
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:119) ~[hibernate-core-6.2.2.Final.jar:6.2.2.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:264) ~[hibernate-core-6.2.2.Final.jar:6.2.2.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractS
segue o resto do erro em imagem