关于jpa连接的glassfish日志中出现奇怪的错误

时间:2019-01-14 09:24:19

标签: java-ee glassfish

我收到此错误:

Error connecting to server localhost on port 1'527 with message Connection refused

详细:

cannot Deploy TestGlassFish
deploy is failing=Error occurred during deployment: Exception while deploying the app [TestGlassFish] : 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.
Error Code: 0. Please see server.log for more details.

我有:

  • 可正常运行的j2ee应用程序。
  • 通过以下方式在我的项目中增加了jpa的功能:

将persistence.xml添加到META-INF文件夹中,我已经证明可以识别出该persistence.xml。

    <?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
    xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <!-- <persistence-unit name="TestPersistence" transaction-type="RESOURCE_LOCAL">-->
    <persistence-unit name="TestPersistence" transaction-type="JTA">
    <!-- <persistence-unit name="TestPersistence">-->
        <!-- <class>javax.persistence.EntityManager</class>-->
        <properties>
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/world?serverTimezone=UTC" />
            <property name="javax.persistence.jdbc.user" value="root" />
            <property name="javax.persistence.jdbc.password" value="xxx" />
        </properties>
    </persistence-unit>
</persistence>
  • 我在端口3306上有一个正在运行的mysql数据库。
  • 我已经通过maven依赖项添加了相应的sql jdbc驱动程序。

为什么我的应用程序尝试连接到1527,我该如何解决呢?

0 个答案:

没有答案