我有一個像這樣的sql查詢。在Jdbc中執行綁定變量執行的Sql查詢
select "DEPT"."DEPTNO" as "DEPTNO1",
"DEPT"."DNAME" as "DNAME1",
"DEPT"."LOC" as "LOC1",
"EMP"."COMM" as "COMM1",
"EMP"."EMPNO" as "EMPNO1",
"EMP"."ENAME" as "ENAME1",
"EMP"."HIREDATE" as "HIREDATE1",
"EMP"."JOB" as "JOB1",
"EMP"."MGR" as "MGR1",
"EMP"."SAL" as "SAL1"
from "EMP" , "DEPT" where "DEPT"."DEPTNO" in (:DeptNo)
//這是JDBC代碼
Class.forName(DB_DRIVER);
dbConnection = DriverManager.getConnection(DB_CONNECTION, DB_USER, DB_PASSWORD);
Statement statment = dbConnection.createStatement();
result = statment.execute(query);//query is above sql query
當我在上面的Oracle SQL Developer查詢運行工作perfectly.But當我上面JDBC代碼運行它,它是投擲並不是所有的變量綁定異常。 如何在JDBC中運行以上查詢
張貼確切的錯誤,你得到PLZ。張貼堆棧跟蹤。張貼你的所有代碼你有PLZ。 –
您的查詢中有一個命名參數(:DeptNo),但您沒有爲其分配值。 – OldProgrammer
ORA-01008:並非所有變量都綁定。我在JDBC上運行sql查詢時得到的這個錯誤 –