我有以下情況...如何正確使用setString過程?
我使用java.sql包中的CallableStatement。當我使用的setDate函數執行存儲過程之前,我得到一個錯誤:
Cannot find symbol symbol: method setDate(int, java.util.Date) location: interface java.sql.CallableStatement"
這裏的示例代碼:
Connection con = null;
CallableStatement proc_stmt = null;
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection("jdbc:sqlserver://servername;databaseName=DBName", "UNAME", "PASS");
proc_stmt = con.prepareCall("{ call InsertSomething(?, ?) }");
proc_stmt.setString(1, "A00999999");
proc_stmt.setDate(2, new Date());
proc_stmt.executeQuery();
proc_stmt.close();
con.close();
我甚至嘗試具有相應功能的這種使用Calendar類,但效果一樣。
你已經打敗了我5秒:-) – NickDK 2009-10-21 12:02:24
非常感謝,這是它 :D;) – Eedoh 2009-10-21 12:07:47
不客氣,Eedoh。 NickDK:下次更好運氣;) – sinuhepop 2009-10-21 13:03:59