在JAVA 中如何调用写在文本文件中的 存贮过程

yinshuai 2002-01-27 06:25:14
在JAVA 中如何调用写在文本文件中的 存贮过程
...全文
103 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
oldcat0076 2002-01-28
  • 打赏
  • 举报
回复
你这样做效率会高吗?你写个存储过程肯定是赋予了它确定的功能,有必要动态生成吗?可能的话,你可以具体说一下你的想法和实际情况。
Washine 2002-01-28
  • 打赏
  • 举报
回复
居然有如此傻瓜的用法!
aprim 2002-01-28
  • 打赏
  • 举报
回复
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.driver.OracleDriver());

// Connect to the database
// You can put a database name after the @ sign in the connection URL.
Connection conn =
DriverManager.getConnection ("jdbc:oracle:oci7:@", "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;");

// 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);
}
}
yinshuai 2002-01-28
  • 打赏
  • 举报
回复
我的意思是说:
为了便于扩充我的存贮过程,我将我的存贮过程直接写到一个文本中,来动态创建我的存储过程。
oldcat0076 2002-01-28
  • 打赏
  • 举报
回复
存储过程放在文本文件中?存储过程如果不在数据库中生成的话是不可能执行的;
如果你只是把一批sql语句放在文本中,则从文本中读出相关sql语句,再用相应方法执行即可
gzgangster 2002-01-28
  • 打赏
  • 举报
回复
呵!也许各人应用不同而已.
你可以把文本文件中的内容用读文件的方式读进来.然后可以先执行个生成存储过程的SQL命令.
或者直接用Statement.Execute("File Text")执行.
pengz 2002-01-27
  • 打赏
  • 举报
回复
我晕!你想干什么???!!!!

23,405

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧