[英]Hitting stored proc - javax.ejb.EJBException
I'm trying to hit a stored procedure but I'm getting this error message: 'javax.ejb.EJBException'... I've never worked with stored procedures so the exception is a bit Greek to me. 我正在尝试访问存储过程,但是却收到此错误消息:'javax.ejb.EJBException'...我从未使用过存储过程,因此该异常对我来说有点希腊。
Anyone that could perhaps shed some light on this? 有人可能对此有所启示吗? Below I pasted the code that I wrote: 下面,我粘贴了我编写的代码:
@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;
}
Oh and the stored procedure us called getSpecimenReportXml ... 哦,存储过程叫getSpecimenReportXml ...
Your exception would say 'caused by' somewhere - which is a big clue. 您的例外情况会在某处说“由...引起”-这是一个大提示。 If it's an NPE then you might want to check the values of dataBaseConnection
and conn
to make sure they've been set. 如果是NPE,则可能要检查dataBaseConnection
和conn
的值以确保已设置它们。 Use a debugger to do this, but the exception should tell you exactly which line caused the problem. 使用调试器可以执行此操作,但是异常应准确告诉您引起问题的行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.