jdbcibm-mobilefirstmobilefirst-adapters

Connect mssql failed with mobile first SQL adapter and jdbc


I am trying to use Mobile First SQL adapter but fail .

When i click "Run as">"Call Mobile First Adapter" on the target adapter , it gives result like:

{
   "errors": [
      "Runtime: java.lang.ClassNotFoundException: Class com.microsoft.sqlserver.jdbc.SQLServerDriver not found in Worklight platform or project \/WangOnPrototype2"
   ],
   "info": [
   ],
   "isSuccessful": false,
   "warnings": [
   ]
}

And the setting in the adapter.xml file is:

<dataSourceDefinition>
    <driverClass>com.microsoft.sqlserver.jdbc.SQLServerDriver</driverClass>

provided that username and password and the ip address are correct and also sqljdbc.jar in added into the project in "Java Build Path".


Solution

  • You were not instructed to place the JDBC driver in the Java Build Path.
    You are supposed to put the driver in the server\lib folder.

    Additionally, the driver class definition is not enough. How do you supply the database URL?

    The complete setup should look like this, with your values, for example:

    <dataSourceDefinition>
       <driverClass>com.microsoft.sqlserver.jdbc.SQLServerDriver</driverClass
       <url>jdbc:sqlserver://localhost\SQLEXPRESS:1433;databaseName=MyDb;</url>
       <user>MyUser</user>
       <password>MyPassword</password>
    </dataSourceDefinition>
    

    See here: IBM Worklight 6.1 - Failed connecting to MS SQL using SQL adapter