import java.sql.CallableStatement; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Types; import cn.itcast.utils.JdbcUtils; public class Demo5 { /* *jdbc调用存储过程 delimiter $$ CREATE PROCEDURE demoSp(IN inputParam VARCHAR(255), INOUT inOutParam varchar(255)) BEGIN SELECT CONCAT('zyxw---', inputParam) into inOutParam; END $$ delimiter ; */ public static void main(String[] args) { Connection conn = null; CallableStatement cs = null; ResultSet rs = null; try{ conn = JdbcUtils.getConnection(); cs = conn.prepareCall("{call demoSp(?,?)}"); cs.setString(1, "xxxxx"); cs.registerOutParameter(2, Types.VARCHAR); cs.execute(); String result = cs.getString(2); System.out.println(result); }catch (Exception e) { e.printStackTrace(); }finally{ JdbcUtils.release(conn, cs, rs); } } }