Accessing mySQL from within Worklight

Hi…

If you want to access a mySQL database from within Worklight, you can add an SQL adapter. Here is a step by step guide:

(1)    Add a database connector by right clicking on your project and selecting New-Worklight Adapter.

Wizzard

(2)    In the requester choose Project Name. Adapter Type is SQL Adapter. Give it a name. If you choose to Create procedures, it will do Javascript stubs in your project.

(3)    You can find the mySQL adapters here http://dev.mysql.com/downloads/connector/ You want to get the J Connector. Download the platform independent version and store it in the server/lib directory. NOTE: You need to restart the server / Eclipse Worklight Studio for the server to recognize the file.

(4)    In the directory adapters in your project you should find your new adapter. Within it carries its configuration.

SuccessWithin the JS files, you find the stubs provided by the wizzard. You need to change the stubs (SQL and JavaScript) according to your needs. Looks like this:

If you right-click on your adapter, you can choose Run as – Invoke Worklight Procedure and test your stuff.

CU

0xff