Ibm mobilefirst IBM Worklight SQL适配器-无法连接到数据库。无法加载JDBC驱动程序类';com.mysql.jdbc.Driver';

Ibm mobilefirst IBM Worklight SQL适配器-无法连接到数据库。无法加载JDBC驱动程序类';com.mysql.jdbc.Driver';,ibm-mobilefirst,worklight-adapters,Ibm Mobilefirst,Worklight Adapters,my adapter.xml <?xml version="1.0" encoding="UTF-8"?> <wl:adapter name="DbConnect" <displayName>DbConnect</displayName> <description>DbConnect</description> <connectivity> <connectionPoli

my adapter.xml

<?xml version="1.0" encoding="UTF-8"?>
<wl:adapter name="DbConnect"

    <displayName>DbConnect</displayName>
    <description>DbConnect</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://localhost:3036/test</url>
                <user>root</user>
                <password>root</password>
            </dataSourceDefinition>
        </connectionPolicy>
        <loadConstraints maxConcurrentConnectionsPerNode="5" />
    </connectivity>

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

</wl:adapter>
我下载了连接器
.jar
驱动程序,并在
服务器/lib
文件夹中找到它。我不明白会出什么问题

编辑:下面是我在worklight mobile browser simulator中运行应用程序时发布的控制台javascript消息

wlclient init started wlgap.android.js:1481
before: app init onSuccess wlgap.android.js:1481
Request [/apps/services/api/Canti_Liturgici/android/query] wlgap.android.js:1481
after: app init onSuccess wlgap.android.js:1481
wlclient init success wlgap.android.js:1481
Failed to load resource: the server responded with a status of 401 (Unauthorized) http://localhost:8080/apps/services/api/Canti_Liturgici/android/query
Request [/apps/services/api/Canti_Liturgici/android/query] wlgap.android.js:1481
response [/apps/services/api/Canti_Liturgici/android/query] success: /*-secure-
{"responseID":"8","errors":["Runtime: org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'"],"isSuccessful":false,"warnings":[],"info":[]}*/ wlgap.android.js:1481
Procedure invocation error. Runtime: org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver' wlgap.android.js:1487
Failure {"status":200,"invocationContext":null,"errorCode":"PROCEDURE_ERROR","errorMsg":"Procedure invocation error. Runtime: org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'","invocationResult":{"responseID":"8","errors":["Runtime: org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'"],"isSuccessful":false,"warnings":[],"info":[]}}

我解决了这个问题。我在
.xml
文件(是3306而不是3036)中编辑了url的端口,还更正了
select()
中的函数
select(语句)

下面两个文件更正

adapter.xml

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

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

你在哪里找到接头的?你下载了哪一个?另外-尝试删除.jar并将其放回原处,它曾经帮助过我一次。@nute我解决了这个问题。我编辑了url的端口(是3306而不是3036),还更正了
select()中的函数
select(statement)
?谢谢。@IdanAdar我有一个问题:如果我想在机器的同一lan上的真实设备上运行应用程序,我必须用lan中机器的ip更改
值,否则我必须做其他事情?你想做的是打开一个新的问题,并提供完整的细节。:)
<displayName>DbConnect</displayName>
    <description>DbConnect</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://localhost:3306/test</url>
                <user>root</user>
                <password>mysql</password>
            </dataSourceDefinition>
        </connectionPolicy>
        <loadConstraints maxConcurrentConnectionsPerNode="5" />
    </connectivity>

    <!-- Replace this with appropriate procedures -->
    <procedure name="remoteDbSize"/>
var statement = WL.Server.createSQLStatement("SELECT SUM( data_length + index_length ) FROM information_schema.TABLES WHERE table_schema =  \"test\" GROUP BY table_schema");
function remoteDbSize() {
    return WL.Server.invokeSQLStatement({
        preparedStatement : statement,
        parameters: []
    });
}