java 如何调用oracle的存储过程?在线等!!!!

flcandclf 2005-07-04 02:12:35
有一账号对象Account,具有以下属性
int id;
String name;
String password;
Date createTime;

能不能给一个java调用oracl存储过程(带参数)的简单列子,功能包括插入、修改、删除、查询,代码包括存储过程和java代码!
...全文
258 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
flcandclf 2005-07-07
  • 打赏
  • 举报
回复
多谢大家,结!
ll42002 2005-07-06
  • 打赏
  • 举报
回复
应该够你用了。
yangbc 2005-07-06
  • 打赏
  • 举报
回复
我们写得差不多了,搂主你应该举一反三,结贴吧
flcandclf 2005-07-06
  • 打赏
  • 举报
回复
怎么就没人再出注意了?
yangbc 2005-07-04
  • 打赏
  • 举报
回复
你们的都不能返回数据集,用我这个可以查询
oracle.jdbc.OracleCallableStatement stmt=
(oracle.jdbc.OracleCallableStatement)conn.prepareCall("" +
"{ call tempPackage.returnRow(?,?)
stmt.setString(1,"1");
stmt.registerOutParameter(2, oracle.jdbc.OracleTypes.CURSOR );
stmt.execute();
laughsmile 2005-07-04
  • 打赏
  • 举报
回复
1.java代码
Connection conn=null;
//取得数据库连接
conn =....;
//准备SQL语句
String strSQL = "{call sp_InsertAccount(?,?,?,?)}";
//准备可调用语句对象
CallableStatement sqlStmt = conn.prepareCall(strSQL);
//设置输入参数
sqlStmt.setInt(1,id);
sqlStmt.setString(2,name);
sqlStmt.setString(3,password);
sqlStmt.setDate(4,createTime);
//登记输出参数
//sqlStmt.registerOutParameter(6,java.sql.Types.Array);
//执行该存储过程
sqlStmt.executeUpdate();
2.存储过程
create procedure sp_InsertAccount(id NUMBER, name VARCHAR2, password VARCHAR2 , createTime date ) as
begin
INSERT INTO Account VALUES (id, name,password,createTime);
end sp_InsertAccount;
simon810610 2005-07-04
  • 打赏
  • 举报
回复
String result="0";
String pro_sql="";
Connection conn=null;
ResultSet rtst=null;
String fetched[]=new String [10];
CallableStatement cs=null;

cs=conn.prepareCall("{call WFP_00003(?,?,?,?)}");
cs.setString(1,oper_id);
cs.setString(2,fetched[0]);
cs.setString(3,fetched[1]);
cs.registerOutParameter(4,Types.VARCHAR);
cs.execute();
zhanghding 2005-07-04
  • 打赏
  • 举报
回复
public void insert(int id ,String name ,String password,Date createtime){
try {
CallableStatement stmt=scon.con.prepareCall("execute 存储名 ?,?,?,?");
stmt.setInt(1,id);
stmt.setString(2,name);
stmt.setString(3,password);
stmt.setDate(4,creattime)
stmt.execute();
stmt.close();
} catch (SQLException e) {

e.printStackTrace();
}
}
flcandclf 2005-07-04
  • 打赏
  • 举报
回复
怎么没人帮我啊?

62,614

社区成员

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

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