使用java调用带出参的存储过程
public class ProceTest {
public static void main(String[] args) throws Exception {
Connection conn = null;
CallableStatement statement = null;
String sql = "{call stu_proc(?)}";
try {
conn = ConnUtils.getConnection();
statement = conn.prepareCall(sql);
statement.registerOutParameter(1, Types.VARCHAR);
statement.executeUpdate();
//输出:lisi
String sname = statement.getString(1);
System.out.println(sname);
} catch (SQLException e) {
e.printStackTrace();
}finally{
ConnUtils.free(null, statement, conn);
}
}
} |