IBM Worklight - Unable to connect to database when using IP address instead of localhost

北城余情 提交于 2020-01-06 12:54:27

问题


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

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)).

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]

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>

回答1:


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.

For example: root@% rather than/in addition to root@localhost.

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

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?



来源:https://stackoverflow.com/questions/23307170/ibm-worklight-unable-to-connect-to-database-when-using-ip-address-instead-of-l

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!