2017-02-19 248 views
1

我使用Apache的ofbiz的,03年7月13日。我構建項目,螞蟻。我改變了數據庫mysql.When我想加載種子/演示數據或螞蟻啓動,日誌顯示錯誤。Ofbiz中:無法建立與數據庫的連接的helperName [localmysql]

***我使用MySQL連接器的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] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964)〜[ mysql-connector-java-5.1.40-bin.jar:5.1.40] [java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3970)〜[mysql-connector-java-5.1.40 -bin.jar:5.1.40] [java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3906)〜[mysql-connector-java-5.1.40-bin.jar:5.1.40] [java] at com.mysql。 jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:873)〜[MySQL的連接器的Java-5.1.40-bin.jar:5.1.40]

我entityengin.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> 
+1

請檢查您的數據庫用戶和權限設置。您可以從錯誤中看到,用戶ofbiz不允許從IP 10.0.31.110訪問您的數據庫。 如需進一步調查,請提供您的相關entityengine.xml設置。 –

+0

@MichaelBrohl我在我的代碼的最後一部分添加了我的entityengin.xml代碼... 我可以通過命令窗口通過命令窗口登錄到我的mysql數據庫通過'**用戶名:ofbiz並傳遞:ofbiz **,因爲我給予ofbiz授予所有權限.. 非常感謝你 –

+0

可能重複[Java JDBC訪問拒絕用戶](http://stackoverflow.com/questions/8224898/java-jdbc-access-denied-for-user) –

回答

0

最後,我能夠找出我的問題,我能夠解決我的問題。

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

這是關於這一行。 每當我創造了我的數據庫架構我已經設置默認字符集設置爲其他格式而不是UTF-8

現在我能連接我的數據庫。非常感謝你們所有人

1

請檢查entityengine.xml配置是否正確。您可以在找到文件 -

/framework/entity/config/entityengine.xml

確保您按照以下步驟 -

  1. 創建數據庫名稱ofbiz的,ofbizolap和mysql中的ofbiztenant。
  2. 轉到framework/entity/config/entityengine.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的用戶名= 「你的MySQL用戶名」

JDBC密碼=「你的MySQL用戶密碼「

希望這可以幫助(Y)

+0

jdbc-username和密碼是正確的。我已經檢查了很多次這個用戶名和密碼。非常感謝你@Nitesh –

+0

這基本上意味着OFBiz無法與數據庫交談。如果您使用的是舊版本的 OFBiz,這可能是由於連接池問題和 最好的解決方法是每隔一段時間重新啓動OFBiz。 如果這總是發生,那麼可能是配置問題,其中 數據庫設置不正確。如果它正在工作並剛剛開始發生,請嘗試 重新啓動OFBiz和數據庫(確保在啓動 OFBiz之前數據庫已啓動)。 –