0
votes

I started using Adapters and I am able to run my application in the Android emulator, but it fails in my Android tablet device.

I tried to change in application-descriptor.xml localhost to 172.16.19.135:8080 but it still failed with this error message:

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

In my Worklight project I have in the HTML a button with an onClick call. I call a SQL Adapter.

This is my SQL adapter:

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" />

connection-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 ]
    });
}

Error:

[http://172.16.19.135:8080/apps/services/api/PrototypesDojo/android/query] Host is not responsive. Try to manually access the URL through the android emulator browser to verify connectivity.

1
Is the device connected to the same network as the Worklight Server?Idan Adar
Not, my tablet is connected to Wi-Fi and my local machine is connected to local area network...Veronica Guapo
That would be your problem then...If 172.16.19.135 cannot be accessed outside of your local network then there is no way for your device to connect to you worklight server. It is also why you are able to connect to it on your emulator.jnortey
Ok,I changed the configuration "Run as" of Eclipse for execute my app on my tablet, but the problem is when I try do the connection with SQL adapter, it show the error "Request timeout for [172.16.19.135:8080/apps/services/api/PrototypesDojo/android/…" How I can connect my Android tablet to Worklight Server? Help me :(, What's the way for connect my device to my worklight server?Veronica Guapo

1 Answers

0
votes

This has got nothing to do with SQL adapters. The actual question/problem here is that you cannot connect your device to the Worklight Server.

In order for a device to connect to the Worklight Server, both the server and device must share the same network.

In a command window, run ipconfig and copy the IPv4 address you are given. Paste this IP address as the value for worklightServerRootURL in the file application-descriptor.xml (located under yourProject\apps\yourApp).