2014-01-22 23 views

回答

1

嘗試此查詢:

在當前的方法,您可以使用:

String storedProc = "{call stored_proc(" + someVariable + ")}"; 

請注意,我用call代替exec,我已經包圍查詢用花括號。

但爲了避免sql injection你可以使用parametrised查詢,如:

String storedProc="{call stored_proc(?)}"; 
PreparedStatement pstmt=connection.prepareStatement(storedProc); 
pstmt.setString(1,someVariable); 
pstmt.execute(storedProc); 
+0

感謝,花括號工作。 – Obaid

+0

@orezavi歡迎 – Bhushan

+0

如何更改此'EXEC spGetCustomerDetails 123455789' –