使用XPages Rest Service连接到MySQL时出错

时间:2019-03-18 16:56:01

标签: mysql rest xpages

尝试通过xpages rest服务连接到mysql数据库时,获得错误500“内部错误”。 MySQL版本8,Domino服务器9.0.1 FP8。 使用来自mysql的JDBC jar文件。 谁能帮助我解决故障排除错误。

错误:

code    500
text    "Internal Error"
message "Error while reading the relational data"
type    "text"
data    "com.ibm.xsp.FacesExceptionEx: Error while reading the relational data
        at com.ibm.xsp.extlib.relational.jdbc.services.content.JsonJdbcQueryContent.writeJdbcQuery(JsonJdbcQueryContent.java:269)
        at com.ibm.xsp.extlib.relational.jdbc.rest.query.RestJdbcQueryJsonService.renderServiceJSONGet(RestJdbcQueryJsonService.java:228)
        at com.ibm.xsp.extlib.relational.jdbc.rest.query.RestJdbcQueryJsonService.renderService(RestJdbcQueryJsonService.java:66)
        at com.ibm.domino.services.HttpServiceEngine.processRequest(HttpServiceEngine.java:168)
        at com.ibm.xsp.extlib.component.rest.UIBaseRestService._processAjaxRequest(UIBaseRestService.java:257)
        at com.ibm.xsp.extlib.component.rest.UIBaseRestService.processAjaxRequest(UIBaseRestService.java:234)
        at com.ibm.xsp.util.AjaxUtilEx.renderAjaxPartialLifecycle(AjaxUtilEx.java:206)
        at com.ibm.xsp.webapp.FacesServletEx.renderAjaxPartial(FacesServletEx.java:249)
        at com.ibm.xsp.webapp.FacesServletEx.serviceAjaxPartialView(FacesServletEx.java:200)
        at com.ibm.xsp.webapp.FacesServletEx.serviceAjaxPartialViewSync(FacesServletEx.java:169)
        at com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:155)
        at com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:159)
        at com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138)
        at com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)
        at com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:588)
        at com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1335)
        at com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:865)
        at com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:808)
        at com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:577)
        at com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1319)
        at com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:662)
        at com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:482)
        at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:357)
        at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:313)
        at com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
    Caused by: java.sql.SQLException
        at com.ibm.xsp.extlib.relational.util.JdbcUtil.createNamedConnection(JdbcUtil.java:87)
        at com.ibm.xsp.extlib.relational.jdbc.services.content.JsonJdbcQueryContent.findConnection(JsonJdbcQueryContent.java:103)
        at com.ibm.xsp.extlib.relational.jdbc.services.content.JsonJdbcQueryContent.writeJdbcQuery(JsonJdbcQueryContent.java:139)
        ... 24 more
    Caused by: javax.naming.NameNotFoundException: comp/env/jdbc/mysqlActor
        at com.ibm.pvc.jndi.internal.provider.java.FlatMappingContext.lookup(FlatMappingContext.java:118)
        at com.ibm.pvc.jndi.internal.provider.java.FlatMappingContext.lookup(FlatMappingContext.java:140)
        at javax.naming.InitialContext.lookup(InitialContext.java:428)
        at com.ibm.xsp.extlib.relational.util.JdbcUtil.createNamedConnection(JdbcUtil.java:81)
        ... 26 more"

xpage xml:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view
    xmlns:xp="http://www.ibm.com/xsp/core"
    xmlns:xe="http://www.ibm.com/xsp/coreex">
    <xp:label
        value="MySQLConnectionTest"
        id="label1">
    </xp:label>
    <xp:br></xp:br>
    <xe:restService
        id="restService1"
        pathInfo="actorData">
        <xe:this.service>
            <xe:jdbcQueryJsonService
                contentType="application/json"
                sqlTable="sakila.actor"
                connectionName="mysqlActor">
            </xe:jdbcQueryJsonService>
        </xe:this.service>
    </xe:restService>

</xp:view>

<?xml version ="1.0" encoding="UTF-8"?>
<jdbc type="dbcp">
    <driver>com.mysql.jdbc.driver</driver>
    <url>jdbc:mysql://9900w7.int.natc-ht.com:3306;databaseName=sakila</url>
    <user>root</user>
    <password>password</password>
    <dbcp>
        <maxTotal>5</maxTotal>
        <maxIdle>5</maxIdle>
    </dbcp>
</jdbc> 

1 个答案:

答案 0 :(得分:0)

这是jdbc配置文件和驱动程序位置的组合。对于mysql,配置需要像下面的示例一样进行配置。感谢Henrik的写作。

<jdbc type="simple">
    <driver>com.mysql.jdbc.Driver</driver>
    <url>jdbc:mysql://9900w7.int.natc-ht.com</url>
    <port>3306</port>
    <databaseName>weather</databaseName>
    <user>root</user>
    <password>password</password>
    <simple>
        <minPoolSize>10</minPoolSize>
        <maxPoolSize>20</maxPoolSize>
    </simple>
</jdbc>