1
我是一名学生,是Java和存储过程的新成员。 我想写一个应该返回一个表格作为Java对象的存储过程。从存储过程中检索Java对象
我有这个表: USER_TABLE(用户标识,USERNAME,DOB)
&程序是:
create or replace procedure "USER_OUT" (USERID in varchar2,UserObj out User)
is
begin
select * from user_table where
USERID = UserObj.USERID;
end USER_OUT;
在Java中我试图调用这个过程和检索对象为: -
CallableStatement callableStatement = dh.con.prepareCall("{call USER_OUT(?)}");
User usr = new User();
callableStatement .setInt (1,"123");
usr1 = (User)callableStatement.getResultSet();
callableStatement.registerOutParameter(1, OracleTypes.CURSOR);
callableStatement.executeUpdate();//getting exception as Object is invalid.
的程序是错误的实现还是我失去了一些东西? 任何帮助真的很感激! 谢谢。
'调用USER_OUT(?)}'只有一个参数。 – Satya
我认为这将是有益的:http://stackoverflow.com/questions/21956042/mapping-a-jdbc-resultset-to-an-object –
对不起,我只是试图说出来,我用(“{call USER_OUT (?,?)}“);也。 – zy31