![](/img/trans.png)
[英]I'm trying to print out prime number but not sure what's wrong with my code
[英]I am not sure what's wrong "Parameter number 2 is not an OUT parameter"
try{
Class.forName("com.mysql.jdbc.Driver");
mycon = DriverManager.getConnection("jdbc:mysql://localhost:3306/schoolDb?autoReconnect=true&useSSL=false", "root", "Banita");
CallableStatement cs = mycon.prepareCall("{call showData(?, ?, ?)}");
cs.setInt(1, 20);
cs.registerOutParameter(2, Types.INTEGER);
cs.registerOutParameter(3, Types.CHAR);
cs.executeUpdate();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
我在這里對創建過程參數做了什么嗎?
CREATE DEFINER=`root`@`localhost` PROCEDURE `showData`(in id int, out deptNO int, out LOC char(12))
BEGIN
select DEPTNO, LOC INTO deptNO, LOC from schooolDb.UDP_DEPT_DNAME where deptNO = id;
END
嘗試
CREATE DEFINER=`root`@`localhost` PROCEDURE `showData`(in id int, out o_deptno int, out o_loc char(12))
BEGIN
select DEPTNO, LOC INTO o_deptno, o_loc from schooolDb.UDP_DEPT_DNAME where DEPTNO = id;
END
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.