試圖執行使用JDBC存儲過程,我似乎無法讓過去這個錯誤,參數1號是不是OUT參數
java.sql.SQLException: Parameter number 1 is not an OUT parameter
public static void SP1() throws SQLException, IOException {
try {
stmt = conn.createStatement();
stmt.executeUpdate("DROP PROCEDURE IF EXISTS sp1;");
stmt.executeUpdate("CREATE PROCEDURE sp1(OUT cName VARCHAR(20))"
+ "SELECT CuratorName FROM curator "
+ "WHERE CuratorPhone = \"90394857\" INTO cName;");
conn.commit();
System.out.println("Sp1 created");
CallableStatement cs3 = conn.prepareCall("{call sp1(?)}");
cs3.registerOutParameter(1, java.sql.Types.VARCHAR);
cs3.execute();
String result = cs3.getString("cName");
System.out.println("Result from sp1:" + result);
} catch (Exception e) {
System.out.println(e);
}
}
該雜質是否獨立運行(即在Java之外)? – 2014-11-21 14:06:24
你正在使用哪些DBMS? – 2014-11-21 14:07:58
我正在使用本地主機上運行的Mysql。我在Netbeans IDE中運行所有東西 – TonyQuig 2014-11-21 14:10:40