gpt4 book ai didi

java - 通过glassfish服务器访问mysql数据库时访问被拒绝

转载 作者:行者123 更新时间:2023-11-29 12:03:05 24 4
gpt4 key购买 nike

我正在学习使用 GlassFish 访问 NetBeans 中的 mysql 数据库的教程。问题是我收到此错误

Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: Access denied for user 'root'@'localhost' (using password: NO)

当我尝试部署我的应用程序时。我了解我需要将密码添加到配置中,以便 GlassFish 可以建立连接。问题是我不确定将其包含在持久性文件中的何处。

<?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="com.mycompany_MyApp_ejb_1.0-SNAPSHOTPU" transaction-type="JTA">
<jta-data-source>jdbc/creditpurchase</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties/>
</persistence-unit>
</persistence>

最佳答案

您可以在 glassfish 管理控制台中编辑属性。 “其他属性”选项卡中的“资源”->“JDBC”->“连接池”->“your_connection_pool”。您可以使用名称密码添加属性。看看here .

关于java - 通过glassfish服务器访问mysql数据库时访问被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32017539/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com