0

我有一个这样的DAO,

public String getCaseTypeById(String caseIdNumber) {
        String caseType = null;

        SqlQuery caseQuery = 
            new PQuery(getDataSource());
        System.out.println("caseIdNumber   --"+caseIdNumber);
        caseType = (String)caseQuery.findObject(caseIdNumber);
        System.out.println("before return");

        return caseType;
    }

并且 pQuery 是

public PlanQuery(DataSource dataSource)
{
    super();
    setDataSource(dataSource);
    BQueries bQueries = new BQueries();

    setSql(bQueries.getSelectStandardCaseTypeQuery());
    declareParameter(new SqlParameter("caseIdNumber",
            Types.NUMERIC));
    compile();
}

getSelectStandardCaseTypeQuery 在哪里,

public String getSelectStandardCaseTypeQuery() {

String selectCaseTypeByCaseId = null;

        selectCaseTypeByCaseId = 
            " SELECT ct.C_CODE as c_code " + 
            "  FROM  " + getSchemaName() + ".csummary cs, " + 
                getSchemaName() + ".ctype ct " +
            "   WHERE cs.c_number = ? " + 
            "   AND UPPER(ct.C_DESC_TEXT) = UPPER(cs.C_TYPE) ";

    return selectCaseTypeByCaseId;
}

现在上面的返回工作正常。控制返回到 DAO 并在 DAO 中打印 sysout 但之后我得到异常,

[从 gpt.csummary cs 中选择 ct.C_CODE 作为 c_type_code,gpt.ctype ct WHERE cs.c_number = ? AND UPPER(ct.C_DESC_TEXT) = UPPER(cs.C_TYPE) ]; 嵌套异常是 java.sql.SQLException: ORA-00942: 表或视图不存在

at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

包装异常:org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; 错误的 SQL 语法 [ SELECT ct.C_CODE as c_type_code FROM gpt.csummary cs, gpt.ctype ct WHERE cs.c_number = ? AND UPPER(ct.C_DESC_TEXT) = UPPER(cs.C_TYPE) ]; 嵌套异常是 java.sql.SQLException: ORA-00942: 表或视图不存在。

但是当我在蟾蜍中执行相同的操作时,一切正常。我看到那个数据库连接模式一切都是正确的。但是为什么在DAO中的finObject中会失败。任何输入?

4

1 回答 1

0

看起来你必须使用:

select * from schema.table_name 
于 2012-12-03T21:36:25.970 回答