0
我adapter.xmlIBM Worklight SQL適配器 - 無法連接到數據庫。無法加載JDBC驅動程序類 'com.mysql.jdbc.Driver'
<?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>
和適配器impl.js
var statement = WL.Server.createSQLStatement("select * from categorie");
function select(statement) {
return WL.Server.invokeSQLStatement({
preparedStatement : statement
});
}
我下載的連接器.jar
驅動程序,並找到它在server/lib
文件夾中。我不明白,這可能是錯的..
編輯:下面我發佈的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":[]}}
你在哪裏找到的連接器?你下載了哪一個?另外 - 嘗試刪除.jar並將其重新放回,它幫助我一次。 –
@nute我解決了這個問題。我編輯了url的端口(是3306而不是3036),我還在'select()中更正了函數'select(statement)'' –
你能寫出這個答案作爲答案並將其標記爲已答覆嗎?謝謝。 –