存储过程:
drop proc h
create proc h
@a int,@b int,@c int output
as
set @c=@a+@b
go
declare @c int
exec h 1,2,@c output
print @c
在java里面:
CallableStatement cs = null;
try {
cs = DBConn.getConnection().prepareCall("{call h(?,?,?)}");
cs.setInt(1,1);
cs.setInt(2,2);
cs.registerOutParameter(3, java.sql.Types.INTEGER);
cs.execute();
int temp=cs.getInt(3);
cs.close();
System.out.println(temp);
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
} catch (SQLException ex) {
ex.printStackTrace();
}
出错内容:
java.sql.SQLException: Output parameter not allowed as argument list prevents use of RPC.
at net.sourceforge.jtds.jdbc.TdsCore.executeSQL(TdsCore.java:993)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:478)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.execute(JtdsPreparedStatement.java:478)
at procdemo.Test3.main(Test3.java:19)
drop proc h
create proc h
@a int,@b int,@c int output
as
set @c=@a+@b
go
declare @c int
exec h 1,2,@c output
print @c
在java里面:
CallableStatement cs = null;
try {
cs = DBConn.getConnection().prepareCall("{call h(?,?,?)}");
cs.setInt(1,1);
cs.setInt(2,2);
cs.registerOutParameter(3, java.sql.Types.INTEGER);
cs.execute();
int temp=cs.getInt(3);
cs.close();
System.out.println(temp);
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
} catch (SQLException ex) {
ex.printStackTrace();
}
出错内容:
java.sql.SQLException: Output parameter not allowed as argument list prevents use of RPC.
at net.sourceforge.jtds.jdbc.TdsCore.executeSQL(TdsCore.java:993)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:478)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.execute(JtdsPreparedStatement.java:478)
at procdemo.Test3.main(Test3.java:19)
解决方案 »
- 有没有朋友知道字节码到底是一个什么东东?
- java里\r和\n的区别是什么?
- MySql是不是不支持中文呀?
- 100分求下面的程序错在哪里?在线等!
- 高手请进,关于读文件的问题?
- 阿里巴巴面试题的java初始化问题
- 数字签名为何速度变的很慢?(答就有分)
- tomcat 连接池配置成功,但是???????
- 有一问题(我是初学者),答复者有分。
- 本人在ibm站点上下载visualage3.5 entry enterprise edition,当每次安装到remove backup files时,安装程序就不动了,请问这时怎么会事
- java连接oracle数据库的问题
- wait()和notify()的问题
标量型用戶自定義函数調用時一定要加所有者
非标量型的(比如你的返回值是表)就不必加存储过程名前加dbo
CallableStatement cs = conn.prepareCall("{call dbo.h(?,?,?)}");