以下的例子转自csdn论坛:
*执行一条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.*"%>
<html>
<body>
<table>
<tr><td>aaa</td><td>bbb</td></tr>
<%
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("<tr><td>" + rs.getstring(1) + "</td><td>" + rs.getstring(2) + "</td></tr>");
}
rs.close();
stmt.close();
conn.close();
%>
</table>
<p>
<%
out.print(conn.isclosed());
%>
</body>
</html>
</body>
</html>