In Java EE, I have a persistence.xml provided and is packaged correctly.
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="ArticleManagement">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.pauljabines.portfolio.Article</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/postgres" />
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
<property name="javax.persistence.jdbc.user" value="postgres" />
<property name="javax.persistence.jdbc.password" value="************************" />
<property name="eclipselink.logging.level" value="ALL" />
</properties>
</persistence-unit>
</persistence>
Question: With these connection properties, why is glassfish throwing error and saying that it can't connect to port 1527?
Here is a bit of the stacktrace:
org.glassfish.deployment.common.DeploymentException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.0.v20170811-d680af5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1,527 with message Connection refused: connect.
The solution for this is to create a jdbc connection pool for postgresql in the glassfish. To do this: