IBM Worklight - 使用IP地址而不是localhost时无法连接到数据库 [英] IBM Worklight - Unable to connect to database when using IP address instead of localhost

查看:339
本文介绍了IBM Worklight - 使用IP地址而不是localhost时无法连接到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在创建一个Worklight应用程序,它从我的计算机的MySQL数据库中检索一些数据。

I'm currently creating a Worklight application that retrieves some data from my computer's MySQL database.

当我尝试运行应用程序时,它无法连接到数据库。当我将数据库的URL更改为IP地址(192.168.6.1(我的计算机的localhost))时,会发生错误。

When I try to run the app, it cannot connect to the database. The error happens when I change the URL of the database to an IP address (192.168.6.1 (my computer's localhost)).

当我通过调用worklight程序(地址是localhost)从我的计算机上测试它时它工作正常,但当我将URL更改为IP地址时,它显示错误:

When I test it from my computer by invoking the worklight procedure (the address is localhost) it works fine, but when I change the URL to the IP address, it shows an error:

[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的连接设置:

Below is the adapter XML's connectivity settings:

<?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地址。

I don't know which database front-end you're using, but you need to go to the user creation/permission screen and make sure you have given the user "root" permission to connect to both localhost and % (all), so that the IP address would be accepted as well.

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

这是提到SQL适配器的幻灯片#14中的培训模块

This is mentioned in slide #14 of the SQL adapter training module.

BTW,您可以将其保留为localhost而不是IP地址(只要您在本地网络中进行测试)。它应该对设备无关紧要。你试过吗?

BTW, you could probably keep it as localhost instead of an IP address (as long as you're testing in your local network). It shouldn't matter for the device. Did you try?

这篇关于IBM Worklight - 使用IP地址而不是localhost时无法连接到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆