CallableStatement proc = null;
proc = connection.prepareCall("{?= call process1(?)}");
其中第一个?是返回的结果值, 利用下面的语句设置返回结果的类型
proc.registerOutParameter(1, Types.INTEGER);
接着后面语句中的?是传递给存储过程的参数值,问号的个数就是参数的个数,可以利用下面的形式向存储过程传递参数:
String ss1 = "ss";
proc.setLong(2, ss1);
proc = connection.prepareCall("{?= call process1(?)}");
其中第一个?是返回的结果值, 利用下面的语句设置返回结果的类型
proc.registerOutParameter(1, Types.INTEGER);
接着后面语句中的?是传递给存储过程的参数值,问号的个数就是参数的个数,可以利用下面的形式向存储过程传递参数:
String ss1 = "ss";
proc.setLong(2, ss1);
解决方案 »
- 练习注解时出现问题了,帮忙看看,代码不多
- JFormattedTextField的问题。
- 复制Jar包时少了META-INFO/MANIFEST.MF
- 怎样使用命令行结束任务计划某个任务
- nio读写的问题:服务器发送两次消息,客户端读取时会获得两条消息的叠加
- 编写一个函数,把一个char(1 char=16bits) 分解成连个byte(1byte=8bits)
- 如何使用jdbc获得指定sql中的表的名称?db2数据库
- JSwing能否支持中文?
- 到什么地方去下载在jbuilder6.0中使用sqlserver2000的驱动程序呀?
- HashMap中的value问题
- ThreadLocal类不会用
- 以下代码如何获取aaa的值,并输出?
* This sample shows how to call a PL/SQL stored procedure using the SQL92
* syntax. See also the other sample PLSQL.java.
*/import java.sql.*;
import java.io.*;class PLSQLExample
{
public static void main (String args [])
throws SQLException, IOException
{
// Load the driver
DriverManager.registerDriver(new oracle.jdbc.OracleDriver()); String url = "jdbc:oracle:oci8:@";
try {
String url1 = System.getProperty("JDBC_URL");
if (url1 != null)
url = url1;
} catch (Exception e) {
// If there is any security exception, ignore it
// and use the default
} // Connect to the database
Connection conn =
DriverManager.getConnection (url, "scott", "tiger"); // Create a statement
Statement stmt = conn.createStatement (); // Create the stored function
stmt.execute ("create or replace function RAISESAL (name CHAR, raise NUMBER) return NUMBER is begin return raise + 100000; end;"); // Close the statement
stmt.close(); // Prepare to call the stored procedure RAISESAL.
// This sample uses the SQL92 syntax
CallableStatement cstmt = conn.prepareCall ("{? = call RAISESAL (?, ?)}"); // Declare that the first ? is a return value of type Int
cstmt.registerOutParameter (1, Types.INTEGER); // We want to raise LESLIE's salary by 20,000
cstmt.setString (2, "LESLIE"); // The name argument is the second ?
cstmt.setInt (3, 20000); // The raise argument is the third ?
// Do the raise
cstmt.execute (); // Get the new salary back
int new_salary = cstmt.getInt (1); System.out.println ("The new salary is: " + new_salary); // Close the statement
cstmt.close(); // Close the connection
conn.close();
}
}
proc.execute();
获得返回的结果值:
proc.getLong(1);