无法将 SQL 服务器连接到 Jakarta 应用程序

Can'l connect SQL Server to Jakarta Application

我在雅加达世界还很陌生。我正在尝试做一个简单的 Rest API 连接到 SQL 服务器。应以 JSON 格式显示的简单实体。当我尝试使用 Glassfish 服务器应用程序部署应用程序时,出现以下错误:

[2022-04-12T03:42:50.974+0300] [glassfish 6.0] [INFO] [] [jakarta.enterprise.system.tools.deployment.common] [tid: _ThreadID=48 _ThreadName=admin-listener(1)] [timeMillis: 1649724170974] [levelValue: 800] [[
  visiting unvisited references]]

[2022-04-12T03:42:51.439+0300] [glassfish 6.0] [INFO] [] [org.eclipse.persistence.session./file:/D:/faculta - mi/Licenta/demo4/target/demo4-1.0-SNAPSHOT/WEB-INF/classes/_default] [tid: _ThreadID=48 _ThreadName=admin-listener(1)] [timeMillis: 1649724171439] [levelValue: 800] [[
  EclipseLink, version: Eclipse Persistence Services - 3.0.0.v202012081010]]

[2022-04-12T03:42:53.746+0300] [glassfish 6.0] [WARNING] [poolmgr.create_resource_error] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.allocator] [tid: _ThreadID=48 _ThreadName=admin-listener(1)] [timeMillis: 1649724173746] [levelValue: 900] [[
[2022-04-12T03:42:53.746+0300] [glassfish 6.0] [WARNING] [poolmgr.get_connection_failure] [javax.enterprise.resource.resourceadapter.com.sun.enterprise.connectors] [tid: _ThreadID=48 _ThreadName=admin-listener(1)] [timeMillis: 1649724173746] [levelValue: 900] [[
[2022-04-12T03:42:53.747+0300] [glassfish 6.0] [WARNING] [jdbc.exc_get_conn] [javax.enterprise.resource.resourceadapter.com.sun.gjc.spi] [tid: _ThreadID=48 _ThreadName=admin-listener(1)] [timeMillis: 1649724173747] [levelValue: 900] [[
  RAR5038:Unexpected exception while creating resource for pool DerbyPool. Exception : jakarta.resource.spi.ResourceAllocationException: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1,527 with message Connection refused: connect.]]

  RAR5117 : Failed to obtain/create connection from connection pool [ DerbyPool ]. Reason : com.sun.appserv.connectors.internal.api.PoolingException: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1,527 with message Connection refused: connect.]]

  RAR5114 : Error allocating connection : [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.]]]

[2022-04-12T03:42:53.747+0300] [glassfish 6.0] [SEVERE] [] [org.eclipse.persistence.session./file:/D:/faculta - mi/Licenta/demo4/target/demo4-1.0-SNAPSHOT/WEB-INF/classes/_default.ejb] [tid: _ThreadID=48 _ThreadName=admin-listener(1)] [timeMillis: 1649724173747] [levelValue: 1000] [[
  
Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 3.0.0.v202012081010): 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.
Error Code: 0
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:319)

Caused by: 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.
at com.sun.gjc.spi.base.AbstractDataSource.getConnection(AbstractDataSource.java:128)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:149)

Caused by: jakarta.resource.spi.ResourceAllocationException: 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.
at com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:295)
a
Caused by: com.sun.appserv.connectors.internal.api.PoolingException: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1,527 with message Connection refused: connect.
at com.sun.enterprise.resource.pool.datastructure.RWLockDataStructure.addResource(RWLockDataStructure.java:79)

Caused by: com.sun.appserv.connectors.internal.api.PoolingException: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1,527 with message Connection refused: connect.
at com.sun.enterprise.resource.pool.ConnectionPool.createSingleResource(ConnectionPool.java:899)

Caus
Caused by: jakarta.resource.spi.ResourceAllocationException: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1,527 with message Connection refused: connect.
at com.sun.gjc.spi.DSManagedConnectionFactory.createManagedConnection(DSManagedConnectionFactory.java:105)

Caused by: java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server localhost on port 1,527 with message Connection refused: connect.

Caused by: ERROR 08001: java.net.ConnectException : Error connecting to server localhost on port 1,527 with message Connection refused: connect.

Caused by: java.net.ConnectException: Connection refused: connect

]]

[2022-04-12T03:42:53.751+0300] [glassfish 6.0] [SEVERE] [] [jakarta.enterprise.system.core] [tid: _ThreadID=48 _ThreadName=admin-listener(1)] [timeMillis: 1649724173751] [levelValue: 1000] [[
  Exception while deploying the app [demo4-1.0-SNAPSHOT]]]

[2022-04-12T03:42:53.751+0300] [glassfish 6.0] [SEVERE] [NCLS-CORE-00026] [jakarta.enterprise.system.core] [tid: _ThreadID=48 _ThreadName=admin-listener(1)] [timeMillis: 1649724173751] [levelValue: 1000] [[
  Exception during lifecycle processing
org.glassfish.deployment.common.DeploymentException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 3.0.0.v202012081010): 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.
Error Code: 0
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:853)

]]

[2022-04-12T03:42:53.762+0300] [glassfish 6.0] [SEVERE] [] [jakarta.enterprise.system.core] [tid: _ThreadID=48 _ThreadName=admin-listener(1)] [timeMillis: 1649724173762] [levelValue: 1000] [[
  Exception while deploying the app [demo4-1.0-SNAPSHOT] : Exception [EclipseLink-4002] (Eclipse Persistence Services - 3.0.0.v202012081010): 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.
Error Code: 0]]

我应该怎么做才能解决这个问题?

P.s.: 我忘了说我在 Intellij 上工作,我已经将 Intellij 连接到 sql 服务器

我通过重新创建 sql 服务器与 glassfish 应用服务器的连接、重新创建连接池和数据源解决了这个问题。那里出了点问题,但我不知道出了什么问题。