Small example of calling Oracle stored procedures in JSP (1)

xiaoxiao2021-03-06  108

* Execute an INSERT statement and pass parameters * / create or replace procedure p_test2 (i in number) AsbeginInsert Into T Values ​​(i, 'x' || to_CHAR (i)); commit; end; /

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

< TD> AAA
BBB <% 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.getstring (1) " rs.getstring (2) " ");}

rs.close (); stmt.close (); conn.close ();%>

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

转载请注明原文地址:https://www.9cbs.com/read-124147.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.055, SQL: 9