apache Ofbiz:无法为helperName [localmysql]建立与数据库的连接

vbkedwbf  于 2023-02-09  发布在  Apache
关注(0)|答案(3)|浏览(172)

我正在使用Apache-ofbiz-13.07.03。我用ant构建项目。我用mysql更改了数据库。当我想加载种子/演示数据或ant start时,日志显示错误。

***我正在使用mysql-connector-java-5.1.40-bin.jar进行JDBC连接

[java] 2017-02-20 00:59:44,209 |OFBiz-config-2       |GenericDelegator              |I| Delegator "default" initializing helper "localmysql" for entity group "org.ofbiz".
 [java] 2017-02-20 00:59:44,209 |OFBiz-config-2       |GenericDelegator              |I| Doing database check as requested in entityengine.xml with addMissing=true
 [java] 2017-02-20 00:59:48,496 |OFBiz-config-2       |DatabaseUtil                  |E| Unable to establish a connection with the database for helperName [localmysql]... Error was: java.sql.SQLException: Unable to acquire a new connection from the pool

 [java] 2017-02-20 00:59:52,572 |main                 |GenericDelegator              |E| Failure in removeByCondition operation for entity [ServiceSemaphore]: org.ofbiz.entity.GenericDataSourceException: Generic Entity Exception occured in deleteByCondition (Unable to esablish a connection with the database. (Unable to acquire a new connection from the pool)). Rolling back transaction.
 [java] org.ofbiz.entity.GenericDataSourceException: Generic Entity Exception occured in deleteByCondition (Unable to esablish a connection with the database. (Unable to acquire a new connection from the pool))
 [java]     at org.ofbiz.entity.datasource.GenericDAO.deleteByCondition(GenericDAO.java:1202) ~[ofbiz-entity-test.jar:?]

[java]... 22更多[java]原因:java.sql.SQLException:用户"ofbiz'@" 10.0.31.110"的访问被拒绝(使用密码:是)[java]在com. mysql. jdbc. SQL错误.创建SQL异常(SQL错误. java:964)~[ mysql-连接器-java-5.1.40-bin. jar:5.1.40][java]在com. mysql. jdbc. MyqlIO.检查错误数据包(MyqlIO. java:3970)~[ mysql-连接器-java-5.1.40-bin. jar:5.1.40][java]在com. mysql. jdbc. MyqlIO.检查错误数据包(MyqlIO. java:3906)~[ mysql-连接器-java-5.1.40-bin. jar:5.1.40][java]在com. mysql. jdbc. MyqlIO.检查错误数据包(MyqlIO. java:873)~[ mysql-连接器-java-5.1.4
我的实体engin.xm就像

<delegator name="default" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" distributed-cache-clear-enabled="false">

     <group-map group-name="org.ofbiz" datasource-name="localmysql"/>
    <group-map group-name="org.ofbiz.olap" datasource-name="localmysqlolap"/>
    <group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/>  

</delegator>

还有我的localmysql部分
其中我的服务器IP是10.0.31.8

    • 我希望与大家分享我可以在本地计算机上成功运行此项目而不会出现任何问题**
<datasource name="localmysql"
        helper-class="org.ofbiz.entity.datasource.GenericHelperDAO"
        field-type-name="mysql"
        check-on-start="true"
        add-missing-on-start="true"
        check-pks-on-start="false"
        use-foreign-keys="true"
        join-style="ansi-no-parenthesis"
        alias-view-columns="false"
        drop-fk-use-foreign-key-keyword="true"
        table-type="InnoDB"
        character-set="latin1"
        collate="latin1_general_cs">
    <read-data reader-name="tenant"/>
    <read-data reader-name="seed"/>
    <read-data reader-name="seed-initial"/>
    <read-data reader-name="demo"/>
    <read-data reader-name="ext"/>
    <read-data reader-name="ext-test"/>
    <read-data reader-name="ext-demo"/>
    <inline-jdbc
            jdbc-driver="com.mysql.jdbc.Driver"
            jdbc-uri="jdbc:mysql://10.0.31.8/ofbiz?autoReconnect=true&amp;characterEncoding=UTF-8"
            jdbc-username="ofbiz"
            jdbc-password="ofbiz"
            isolation-level="ReadCommitted"
            pool-minsize="2"
            pool-maxsize="250"
            time-between-eviction-runs-millis="600000"/><!-- Please note that at least one person has experienced a problem with this value with MySQL
            and had to set it to -1 in order to avoid this issue.
            For more look at http://markmail.org/thread/5sivpykv7xkl66px and http://commons.apache.org/dbcp/configuration.html-->
    <!-- <jndi-jdbc jndi-server-name="localjndi" jndi-name="java:/MySqlDataSource" isolation-level="Serializable"/> -->
</datasource>
rmbxnbpk

rmbxnbpk1#

请检查entityengine.xml是否配置正确。您可以在以下位置找到该文件-
/framework/entity/config/entityengine.xml
请确保您已遵循以下步骤-
1.在mysql中创建名为ofbiz,ofbizolap和ofbiztenant的数据库。
1.转到framework/实体/config/实体引擎. xml并按如下所示进行更改。

<group-map group-name="org.ofbiz" datasource-name="localmysql"/>
<group-map group-name="org.ofbiz.olap" datasource-name="localmysqlolap"/>
<group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/>
<group-map group-name="org.ofbiz" datasource-name="localmysql"/>
<group-map group-name="org.ofbiz.olap" datasource-name="localmysqlolap"/>
<group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/>
<group-map group-name="org.ofbiz" datasource-name="localmysql"/>
<group-map group-name="org.ofbiz.olap" datasource-name="localmysqlolap"/>
<group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/>

并在数据源localmysql、localmysqlolap、localmysqltenant中更改以下属性:
jdbc-username=“您的mysql用户名”
jdbc-password=“您的mysql用户密码”
希望这可能有所帮助(Y)

o2gm4chl

o2gm4chl2#

最后,我能够找到我的问题,我能够解决我的问题。

jdbc-uri="jdbc:mysql://localhost/ofbiz?autoReconnect=true&amp;characterEncoding=UTF-8"

这是所有关于这一行。2每当我创建我的数据库模式时,我已经将默认字符集设置为其他格式而不是UTF-8
现在我可以连接我的数据库了。2非常感谢你们

vpfxa7rd

vpfxa7rd3#

jdbc-uri="jdbc:mysql://ServerIp/ofbiz?autoReconnect=true&amp;characterEncoding=UTF-8&amp;useSSL=false"
mysql连接器是8.0.11我设置了useSSL=false,它工作正常

相关问题