IBM Worklight — невозможно подключиться к базе данных при использовании IP-адреса вместо локального хоста

В настоящее время я создаю приложение Worklight, которое извлекает некоторые данные из базы данных MySQL моего компьютера.

Когда я пытаюсь запустить приложение, оно не может подключиться к базе данных. Ошибка возникает, когда я меняю URL-адрес базы данных на IP-адрес (192.168.6.1 (локальный хост моего компьютера)).

Когда я тестирую его со своего компьютера, вызывая процедуру worklight (адрес — localhost), он работает нормально, но когда я меняю URL-адрес на IP-адрес, он показывает ошибку:

[ERROR   ] FWLSE0012E: ERROR: Could not connect to database. Cannot create PoolableConnectionFactory (null,  message from server: "Host 'stephen-PC' is not allowed to connect to this MySQL server"). [project BarcodeScannerSample]
[ERROR   ] FWLSE0012E: ERROR: Could not connect to database. Cannot create PoolableConnectionFactory (null,  message from server: "Host 'stephen-PC' is not allowed to connect to this MySQL server"). [project BarcodeScannerSample]
[ERROR   ] FWLSE0012E: ERROR: Could not connect to database. Cannot create PoolableConnectionFactory (null,  message from server: "Host 'stephen-PC' is not allowed to connect to this MySQL server"). [project BarcodeScannerSample]
[ERROR   ] FWLSE0012E: ERROR: Could not connect to database. Cannot create PoolableConnectionFactory (Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.). [project BarcodeScannerSample]
[ERROR   ] FWLSE0012E: ERROR: Could not connect to database. Cannot create PoolableConnectionFactory (Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.). [project BarcodeScannerSample]
[ERROR   ] FWLSE0020E: Ajax request exception: There is no application in the DB with the id 'BarcodeScannerSampleApp'. [project BarcodeScannerSample]
[ERROR   ] FWLSE0117E: Error code: 1, error description: INTERNAL_ERROR, error message: FWLSE0069E: An internal error occurred during gadget request  [project BarcodeScannerSample]There is no application in the DB with the id 'BarcodeScannerSampleApp'., User Identity {SubscribeServlet=null, wl_authenticityRealm=null, wl_remoteDisableRealm=null, SampleAppRealm=null, wl_antiXSRFRealm=null, wl_deviceAutoProvisioningRealm=null, WorklightConsole=null, wl_deviceNoProvisioningRealm=null, wl_anonymousUserRealm=null}. [project BarcodeScannerSample] 
                                                                                                               com.worklight.common.log.filters.ErrorFilter
[ERROR   ] FWLSE0012E: ERROR: Could not connect to database. Cannot create PoolableConnectionFactory (null,  message from server: "Host 'stephen-PC' is not allowed to connect to this MySQL server"). [project BarcodeScannerSample]
[ERROR   ] FWLSE0020E: Ajax request exception: There is no application in the DB with the id 'BarcodeScannerSampleApp'. [project BarcodeScannerSample]
[ERROR   ] FWLSE0117E: Error code: 1, error description: INTERNAL_ERROR, error message: FWLSE0069E: An internal error occurred during gadget request  [project BarcodeScannerSample]There is no application in the DB with the id 'BarcodeScannerSampleApp'., User Identity {SubscribeServlet=null, wl_authenticityRealm=null, wl_remoteDisableRealm=null, SampleAppRealm=null, wl_antiXSRFRealm=null, wl_deviceAutoProvisioningRealm=null, WorklightConsole=null, wl_deviceNoProvisioningRealm=null, wl_anonymousUserRealm=null}. [project BarcodeScannerSample] 
                                                                                                               com.worklight.common.log.filters.ErrorFilter
[ERROR   ] FWLSE0020E: Ajax request exception: There is no application in the DB with the id 'BarcodeScannerSampleApp'. [project BarcodeScannerSample]
[ERROR   ] FWLSE0117E: Error code: 1, error description: INTERNAL_ERROR, error message: FWLSE0069E: An internal error occurred during gadget request  [project BarcodeScannerSample]There is no application in the DB with the id 'BarcodeScannerSampleApp'., User Identity {SubscribeServlet=null, wl_authenticityRealm=null, wl_remoteDisableRealm=null, SampleAppRealm=null, wl_antiXSRFRealm=null, wl_deviceAutoProvisioningRealm=null, WorklightConsole=null, wl_deviceNoProvisioningRealm=null, wl_anonymousUserRealm=null}. [project BarcodeScannerSample] 
                                                                                                               com.worklight.common.log.filters.ErrorFilter
[ERROR   ] FWLSE0020E: Ajax request exception: There is no application in the DB with the id 'BarcodeScannerSampleApp'. [project BarcodeScannerSample]
[ERROR   ] FWLSE0117E: Error code: 1, error description: INTERNAL_ERROR, error message: FWLSE0069E: An internal error occurred during gadget request  [project BarcodeScannerSample]There is no application in the DB with the id 'BarcodeScannerSampleApp'., User Identity {SubscribeServlet=null, wl_authenticityRealm=null, wl_remoteDisableRealm=null, SampleAppRealm=null, wl_antiXSRFRealm=null, wl_deviceAutoProvisioningRealm=null, WorklightConsole=null, wl_deviceNoProvisioningRealm=null, wl_anonymousUserRealm=null}. [project BarcodeScannerSample] 
                                                                                                               com.worklight.common.log.filters.ErrorFilter
[ERROR   ] FWLSE0020E: Ajax request exception: There is no application in the DB with the id 'BarcodeScannerSampleApp'. [project BarcodeScannerSample]
[ERROR   ] FWLSE0117E: Error code: 1, error description: INTERNAL_ERROR, error message: FWLSE0069E: An internal error occurred during gadget request  [project BarcodeScannerSample]There is no application in the DB with the id 'BarcodeScannerSampleApp'., User Identity {SubscribeServlet=null, wl_authenticityRealm=null, wl_remoteDisableRealm=null, SampleAppRealm=null, wl_antiXSRFRealm=null, wl_deviceAutoProvisioningRealm=null, WorklightConsole=null, wl_deviceNoProvisioningRealm=null, wl_anonymousUserRealm=null}. [project BarcodeScannerSample] 
                                                                                                               com.worklight.common.log.filters.ErrorFilter
[WARNING ] FWLSE0082W: Failed to deploy adapter. This may be due to a JavaScript error in your adapter implementation (archive:  'C:\Users\stephen\AppData\Local\Temp\loginAdapter7158962596204999276.adapter'). [project mywatermelon]
The 'adapter' version '6.1.0.00.20131219-1900' is different than the version of Worklight Server '6.0.0'. 
Use Worklight Studio '6.0.0' to build and deploy the application.
[WARNING ] FWLSE0082W: Failed to deploy adapter. This may be due to a JavaScript error in your adapter implementation (archive:  'C:\Users\stephen\AppData\Local\Temp\myRESTAdapter36508485292314915.adapter'). [project mywatermelon]
The 'adapter' version '6.1.0.00.20131219-1900' is different than the version of Worklight Server '6.0.0'. 
Use Worklight Studio '6.0.0' to build and deploy the application.
[ERROR   ] FWLSE0012E: ERROR: Could not connect to database. Cannot create PoolableConnectionFactory (null,  message from server: "Host 'stephen-PC' is not allowed to connect to this MySQL server"). [project BarcodeScannerSample]

Ниже приведены настройки подключения адаптера XML:

<?xml version="1.0" encoding="UTF-8"?>
...
...
  <connectivity>
    <connectionPolicy xsi:type="sql:SQLConnectionPolicy">
      <!-- Example for using a JNDI data source, replace with actual data source name -->
      <!-- <dataSourceJNDIName>java:/data-source-jndi-name</dataSourceJNDIName> -->

      <!-- Example for using MySQL connector, do not forget to put the MySQL connector library in the project's lib folder -->
      <dataSourceDefinition>
        <driverClass>com.mysql.jdbc.Driver</driverClass>
        <url>jdbc:mysql://192.168.6.1:3306/barcode</url>
          <user>root</user>
          <password>170693</password> 
      </dataSourceDefinition>
    </connectionPolicy>
    <loadConstraints maxConcurrentConnectionsPerNode="5" />
  </connectivity>
  ...
  ...
</wl:adapter>

person stephen1706    schedule 26.04.2014    source источник


Ответы (1)


Я не знаю, какой внешний интерфейс базы данных вы используете, но вам нужно перейти к экрану создания/разрешения пользователя и убедиться, что вы предоставили пользователю «root» разрешение на подключение как к localhost, так и к % (всем), чтобы IP-адрес также принимался.

Например: root@% вместо/в дополнение к root@localhost.

Это упоминается на слайде № 14 Учебный модуль по адаптеру SQL.

Кстати, вы, вероятно, могли бы сохранить его как локальный хост вместо IP-адреса (пока вы тестируете в своей локальной сети). Для устройства это не должно иметь значения. Ты пробовал?

person Idan Adar    schedule 26.04.2014
comment
извините, но я не знаю, как это реализовать. я использую соединение jdbc для доступа к базе данных mysql, и я использую phpmyadmin для управления базой данных - person stephen1706; 26.04.2014
comment
да, я пытался проверить это, используя localhost в качестве IP-адреса, но это не работает - person stephen1706; 26.04.2014
comment
Тогда вам нужно будет разобраться. Прочтите документацию по phpmyadmin. - person Idan Adar; 26.04.2014
comment
Быстрый поиск в гугле выдал это. Запустите поиск Google. wiki.phpmyadmin.net/pma/user_management - person Idan Adar; 26.04.2014
comment
отлично, это наконец-то работает после того, как я изменил привилегию. большое спасибо! - person stephen1706; 26.04.2014