create procedure dat(
@d datetime,
@e datetime,
@LEFT datetime,
@day int)
as
begin
set @d=(SELECT (DATEADD(WEEK, DATEDIFF(WEEK, 0,DATEADD(DAY,6-DATEPART(DAY,GETDATE()),GETDATE())), 0) +28))
set @e=( select SYSDATETIME ())
SET @LEFT=@d-@e;
set @day=(select DAY(@LEFT))
select region,cast((((TOTAL*55)/100)-(CAST((SUM(EMI)/100) AS DECIMAL(2,2))+CAST((SUM([REPO ARREAR])/100) AS DECIMAL(2,2))))/@day as decimal(3,3)) DRR from DCC GROUP BY TOTAL ,CIRCLE ,REGION ORDER BY CIRCLE,REGION
end
这是我的程序。我正在SQL Server 2008中编写此过程。
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=Repo;user=sa;password=sam123;");
String SQL=("{call [DCR].[dbo].[dat]()}");
CallableStatement cs = con.prepareCall(SQL);
rss=cs.executeQuery();
while(rss.next())
{
float day=rss.getFloat(2);
}
}
catch(Exception e){
}
这是我的jsp代码。我没有得到ResultSet中的值。请帮帮我。
答案 0 :(得分:0)
你不能从JSP调用一个过程,这不是这样做的方法。它需要用Java完成,如下所示
CallableStatement sqlCallStmt = null;
sqlCallStmt = connection.prepareCall("{call Time(?,?)}")
sqlCallStmt.registerOutParameter(1, java.sql.Types.VARCHAR);
sqlCallStmt.setString(2,test);
sqlCallStmt.execute();