jdbc와 함께 HANA에 HANA 저장 절차에 대한 구문 오류 호출 절차

StackOverflow https://stackoverflow.com/questions/19845652

  •  29-07-2022
  •  | 
  •  

문제

HANA 저장 절차를 호출하는 구문 오류가 발생합니다. HANA Studio의 SQL 편집기에서는 작동하지만 구문은 Java의 PrepareCall에 대해 달라야합니다. 나는 그것이 패키지 이름의 전진 슬래시라고 생각하지만 그것에 대해 무엇을 해야할지 잘 모르겠습니다.

컨텐츠 폴더 아래에서 저장 프로 시저를 만들었 기 때문입니까? 다른 곳에 건축해야합니까?

연결 및 전화는 다음과 같습니다. 연결은 괜찮습니다

            Class.forName("com.sap.db.jdbc.Driver");

            String url = "jdbc:sap://10.9.9.139:30015/GL1";
            String user = "userid";
            String password = "password";

            cn = java.sql.DriverManager.getConnection(url, user, password);

            if (cn == null) {
                System.out.println("failed");
            }

            cs = cn.prepareCall("call '_SYS_BIC'.'myPackaged/ZMM_PR_MATERIALS_GET'"); <---- THROWS EXCEPTION BELOW
            rs = cs.executeQuery();
            while(rs.next()) {
                System.out.println(rs.getString(0));
            }
        } catch(Exception e) {
            e.printStackTrace();
        }

// this WORKS FINE... i get a connection and get some records.    
//          rs = cn.createStatement().executeQuery("SELECT * FROM MYSCHEMA.ORDERS");
//          int i = 0;
//          while (rs.next()) {
//              System.out.println(String.format("rec %2d: %s=%2s", ++i, "ORDER_ID", rs.getString("ORDER_ID")));
//          }



com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: [257]: sql syntax error: incorrect syntax near "_SYS_BIC": line 1 col 6 (at pos 6)
    at com.sap.db.jdbc.exceptions.SQLExceptionSapDB.createException(SQLExceptionSapDB.java:334)
    at com.sap.db.jdbc.exceptions.SQLExceptionSapDB.generateDatabaseException(SQLExceptionSapDB.java:174)
    at com.sap.db.jdbc.packet.ReplyPacket.buildExceptionChain(ReplyPacket.java:104)
    at com.sap.db.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:1106)
    at com.sap.db.jdbc.CallableStatementSapDB.sendCommand(CallableStatementSapDB.java:1961)
    at com.sap.db.jdbc.StatementSapDB.sendSQL(StatementSapDB.java:972)
    at com.sap.db.jdbc.CallableStatementSapDB.doParse(CallableStatementSapDB.java:253)
    at com.sap.db.jdbc.CallableStatementSapDB.constructor(CallableStatementSapDB.java:212)
    at com.sap.db.jdbc.CallableStatementSapDB.<init>(CallableStatementSapDB.java:123)
    at com.sap.db.jdbc.CallableStatementSapDBFinalize.<init>(CallableStatementSapDBFinalize.java:31)
    at com.sap.db.jdbc.ConnectionSapDB.prepareCall(ConnectionSapDB.java:1295)
    at com.sap.db.jdbc.trace.Connection.prepareCall(Connection.java:318)
    at com.glazers.hana.utils.HanaStoredProcedure.execute(HanaStoredProcedure.java:54)
    at com.glazers.hana.utils.HanaStoredProcedure.main(HanaStoredProcedure.java:20)
도움이 되었습니까?

해결책

저장된 절차 호출의 문제는 이중 인용문을 피하지 않았다는 것입니다. 구문은 패키지와 전방 슬래시를 올바르게 처리하기 위해서는 여전히 이중 따옴표가 필요합니다. @mark rotteveel, 당신은 가까웠습니다. 나는 단일 따옴표를 이중 따옴표로 대체 할 수 없습니다. 이것은 작동하는 것입니다 : cn.preparecall ( "Call "_ sys_bic ". "myPackaged/zmm_pr_materials_get "")

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top