2013-04-10 74 views
0

我开始使用适配器,我可以在Android模拟器中运行我的应用程序,但在我的Android平板电脑设备中失败。工作灯SQL适配器部署

我试着在应用descriptor.xml localhost来改变172.16.19.135:8080但它仍然失败,此错误消息:

"Request timeout for [http://172.16.19.135:8080/apps/services/api/PrototypesDojo/android/query]"

在我的工作灯的项目我在HTML有一个按钮拨打onClick。我称之为SQL适配器。

这是我的SQL适配器:

connection.xml

<displayName>connexion</displayName> 
<description>connexion</description> 
<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://worklight:3306/test</url> 
      <user>root</user> 
      <password>myRootPassword</password> 
     </dataSourceDefinition> 
    </connectionPolicy> 
    <loadConstraints maxConcurrentConnectionsPerNode="5" /> 
</connectivity> 

<!-- Replace this with appropriate procedures --> 
<procedure name="authentification" /> 
<procedure name="creerCompte" /> 

连接impl.js

var requeteStatement = WL.Server 
     .createSQLStatement("select login,password from compte where login = ? and password = ?"); 


function authentification(login, password) { 

    return WL.Server.invokeSQLStatement({ 
     preparedStatement : requeteStatement, 
     parameters : [ login, password ] 
    }); 
} 

错误:

[http://172.16.19.135:8080/apps/services/api/PrototypesDojo/android/query]主机没有响应。尝试通过Android模拟器浏览器手动访问URL以验证连接。

+0

设备是否连接到与Worklight Server相同的网络? – 2013-04-10 14:48:03

+0

不是,我的平板电脑已连接到Wi-Fi,并且我的本地计算机已连接到局域网... – 2013-04-10 15:10:14

+0

那将是您的问题,然后...如果172.16.19.135无法在您的本地网络之外访问,则不存在让您的设备连接到您的worklight服务器。这也是您能够在模拟器上连接到它的原因。 – jnortey 2013-04-10 18:24:36

回答

0

这与SQL适配器无关。 这里的实际问题是您无法将设备连接到Worklight Server。

为了让设备连接到Worklight Server,服务器和设备必须共享相同的网络。

在命令窗口中,运行ipconfig并复制给出的IPv4地址。将此IP地址作为worklightServerRootURL的值粘贴到文件application-descriptor.xml中(位于您的Project \ apps \ yourApp下)。

+0

好吧,我这样做了,我将我的IP地址(172.16.19.135)粘贴到,然后我在我的设备上执行了我的worklight项目,给我看看html main,当我点击我的按钮“Connecter”时,我无法连接到数据库,显示错误 – 2013-04-11 07:49:59

+0

编辑你的问题并提供关于你如何连接到数据库的信息你的函数,您的适配器XML,... – 2013-04-11 07:51:28

+0

感谢您的回答...请帮助我:) – 2013-04-11 07:54:46