mysql - IBM Worklight - 使用 IP 地址而不是本地主机时无法连接到数据库

标签 mysql ibm-mobilefirst worklight-adapters

我当前正在创建一个 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>

最佳答案

我不知道您正在使用哪个数据库前端,但您需要转到用户创建/权限屏幕并确保您已授予用户“root”权限以连接到两个localhost %(全部),这样 IP 地址也会被接受。

例如:root@% 而不是/除了 root@localhost

提到了这个in slide #14 of the SQL adapter training module .

顺便说一句,您可以将其保留为本地主机而不是 IP 地址(只要您在本地网络中进行测试)。对于设备来说应该没什么影响。你尝试过吗?

关于mysql - IBM Worklight - 使用 IP 地址而不是本地主机时无法连接到数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23307170/

相关文章:

android - 如何将 .aar 文件转换为 .jar

hybrid-mobile-app - 当没有连接到适配器时防止 "onSuccess"触发?

mysql - IBM Worklight - 调用存储过程时如何获取 OUT 参数?

php - 照片上传在本地主机上工作但在服务器上不起作用?

android - Google Play Worklight 6.2.0 上的 OpenSSL 警告

MySql-从三个表中选择不同的值

javascript - 在 sql 适配器过程中使用 WL.Server.invokeSQLStatement 返回的结果集

javascript - worklight 从 mysql 获取图像 blob

php - Laravel Eloquent 地返回一个无符号整数列的记录限制为 2147483647

php - 如何以json格式php从数据库中获取所有项目?