Java??洢???????÷???
???????????? ???????[ 2014/11/6 11:13:13 ] ????????Java ???? ???????
???????Java????????洢?????????
????A??????????????
create procedure getsum
@n int =0<--???????-->
as
declare @sum int<--???????-->
declare @i int
set @sum=0
set @i=0
while @i<=@n begin
set @sum=@sum+@i
set @i=@i+1
end
print 'the sum is '+ltrim(rtrim(str(@sum)))
??????SQL?????У?
????exec getsum 100
??????JAVA?е????
????JAVA??????? ??????JAVA???????????????洢??????? ?????????洢????????????int ????????in(???)???
import java.sql.*;
public class ProcedureTest
{
public static void main(String args[]) throws Exception
{
//????????
DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());
//???????
Connection conn=DriverManager.getConnection("jdbc:odbc:mydata"??"sa"??"");
//?????洢????????
CallableStatement c=conn.prepareCall("{call getsum(?)}");
//???洢?????????????
c.setInt(1??100); //????????????????ó?100
//???д洢????
c.execute();
conn.close();
}
}
????B????????????
????1:????int
alter procedure getsum
@n int =0??
@result int output
as
declare @sum int
declare @i int
set @sum=0
set @i=0
while @i<=@n begin
set @sum=@sum+@i
set @i=@i+1
end
set @result=@sum
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11