当前位置: 技术问答>java相关
帮我看一下程序,java调用oracle数据存储的问题?
来源: 互联网 发布时间:2015-07-20
本文导语: 数据存储: create or replace procedure all_users_seleproc is v_username all_users.username%type; begin select username into v_username from all_users where user_id = 5 ; end all_users_seleproc; //我只想调用存储,取出里面的v_userna...
数据存储:
create or replace procedure all_users_seleproc
is
v_username all_users.username%type;
begin
select username into v_username from all_users
where user_id = 5 ;
end all_users_seleproc;
//我只想调用存储,取出里面的v_username,该如何实现
java程序
CallableStatement cs = con.prepareCall( "? ={call all_users_seleproc}");
cs.registerOutParameter(1, java.sql.Types.CHAR);(这一步怎么写,注册输出字段)
ResultSet rs = cs.executeQuery();
user=rs.getString("username");//username为数据库字段名称
System.out.println("user");
存储应该没有错误,java程序那里错了,给写一下上面几句
|
cs = con.prepareCall("{call all_users_seleproc()}");
cs.execute();
user=cs.getString("username");
cs.execute();
user=cs.getString("username");