ITPub博客

首页 > Linux操作系统 > Linux操作系统 > [转载]Jsp中调用Oracle存储过程的小例子

[转载]Jsp中调用Oracle存储过程的小例子

原创 Linux操作系统 作者:dinner1007 时间:2019-06-18 12:06:07 0 删除 编辑
Jsp中调用Oracle存储过程的小例子
*执行一条insert语句并传参数*/
create or replace procedure p_test2(i in number) as
begin
insert into t values (i,'x'||to_char(i));
commit;
end;
/

<%@ page language="java" contentType="text/html;charset=gb2312"%>
<%@page import="java.sql.*"%>




<%
String driver = "oracle.jdbc.driver.OracleDriver";
String strUrl = "jdbc:oracle:thin:@192.168.1.6:1521:db";

Class.forName(driver);
Connection conn = DriverManager.getConnection(strUrl, "scott", "tiger");

String procedure = "{call p_test2 (?) }";
CallableStatement cstmt = conn.prepareCall(procedure);
cstmt.setInt(1,33);
cstmt.executeUpdate();

Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from t");

while(rs.next())
{
out.println("");
}

rs.close();
stmt.close();
conn.close();
%>
aaabbb
" + rs.getString(1) + "" + rs.getString(2) + "


<%
out.print(conn.isClosed());
%>




来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/374079/viewspace-131177/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2018-08-23

  • 博文量
    1714
  • 访问量
    1290394