点击存储过程 - javax.ejb.EJBException

时间:2011-10-17 14:00:50

标签: java sql stored-procedures jdbc ejb

我正在尝试访问存储过程,但是我收到此错误消息:'javax.ejb.EJBException'...我从未使用过存储过程,所以异常对我来说有点希腊语。< / p>

任何人都可以对此有所了解?下面我粘贴了我写的代码:

@WebMethod(operationName = "getSpecimenResultsXml")
public String getSpecimenResultsXml(@WebParam(name = "specimenGuid") String specimenGuid, @WebParam(name = "publicationGuid") String publicationGuid, @WebParam(name = "forProvider") String forProvider) {

    //Method variables
    ResultSet rs = null;
    String xml = null;

    // 1) get server connection
    Connection conn = dataBaseConnection.getConnection();

    // 2) Pass recieved parameters to stored proc.
    try {
        CallableStatement proc =
                conn.prepareCall("{ call getSpecimenReportXml(?, ?, ?) }");
        proc.setString(1, specimenGuid);
        proc.setString(2, publicationGuid);
        proc.setString(3, forProvider);
        proc.execute();

        rs = proc.getResultSet();

    } catch (SQLException e) {
        System.out.println("--------------Error in getSpecimenResultsXml------------");
        System.out.println("Cannot call stored proc: " + e);
        System.out.println("--------------------------------------------------------");
    }

    // 3) Get String from result set
    try {
        xml = rs.getString(1);
    } catch (SQLException e) {
        System.out.println("--------------Error in getSpecimenResultsXml------------");
        System.out.println("Cannot retrieve result set: " + e);
        System.out.println("--------------------------------------------------------");
    }

    // 4) close connection
    try {
        conn.close();
    } catch (Exception e) {
        System.out.println("--------------Error in getSpecimenResultsXml------------");
        System.out.println("Cannot close connection: " + e);
        System.out.println("--------------------------------------------------------");
    }

    // 5) return the returned String
    return xml;
}

哦,存储过程叫做 getSpecimenReportXml ......

1 个答案:

答案 0 :(得分:0)

你的例外会说“由某个地方造成的 - 这是一个很大的线索。如果它是NPE,那么您可能需要检查dataBaseConnectionconn的值以确保它们已设置。使用调试器执行此操作,但异常应该告诉您确切的哪一行导致了问题。