java 调用存储过程 怎么用? 30
CreatePROCEDUREproc_ViewSendinfo@bidintasdeclare@EndDateintset@EndDate=0while(@EndDat...
Create PROCEDURE proc_ViewSendinfo @bid int
as
declare @EndDate int
set @EndDate=0
while (@EndDate<7)
begin
select count(*) from sendinfo left join staffinfo on(sendinfo.sid = staffinfo.sid)
where convert(varchar(20),sendinfo.sdata,101) = convert(varchar(20),dateadd(day,@EndDate,getdate()),101)
and staffinfo.bid = @bid and sendinfo.stime = 1
group by sendinfo.stime,staffinfo.bid
set @EndDate = @EndDate +1
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
我的这个存储过程 怎么调用 它查出来的是7条纪录!!!!!
我的方法
Vector vec = new Vector();
// 定义一个 字符串连接
StringBuffer sb = null;
//定义一个数据库连接对象
BaseConnection db = null;
db = new BaseConnection();
sb = new StringBuffer();
ResultSet rs = null;
sb.append("exec proc_ViewSendinfo ");
sb.append(""+branch.getBid()+"");
System.out.println("SQL:"+sb.toString());
rs = db.executeMyQuery(sb.toString());
try {
while(rs.next()){
ViewSendTO view = new ViewSendTO();
view.setOne(rs.getInt(1));
vec.addElement(view);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return vec;
这样 只能查出一条!!怎么处理???????????? 展开
as
declare @EndDate int
set @EndDate=0
while (@EndDate<7)
begin
select count(*) from sendinfo left join staffinfo on(sendinfo.sid = staffinfo.sid)
where convert(varchar(20),sendinfo.sdata,101) = convert(varchar(20),dateadd(day,@EndDate,getdate()),101)
and staffinfo.bid = @bid and sendinfo.stime = 1
group by sendinfo.stime,staffinfo.bid
set @EndDate = @EndDate +1
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
我的这个存储过程 怎么调用 它查出来的是7条纪录!!!!!
我的方法
Vector vec = new Vector();
// 定义一个 字符串连接
StringBuffer sb = null;
//定义一个数据库连接对象
BaseConnection db = null;
db = new BaseConnection();
sb = new StringBuffer();
ResultSet rs = null;
sb.append("exec proc_ViewSendinfo ");
sb.append(""+branch.getBid()+"");
System.out.println("SQL:"+sb.toString());
rs = db.executeMyQuery(sb.toString());
try {
while(rs.next()){
ViewSendTO view = new ViewSendTO();
view.setOne(rs.getInt(1));
vec.addElement(view);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return vec;
这样 只能查出一条!!怎么处理???????????? 展开
2个回答
展开全部
给你个我以前做的例子吧
public void proselect(){
PreparedStatement pstmt=null;
Connection conn=null;
ResultSet rs=null;
conn=com.opendb.OpenDB.conn();//这个只是建立个连接
try {
pstmt = conn.prepareCall("call sel");//调用存储过程sel ,sel代码为select * from test
rs=pstmt.executeQuery();
System.out.println(rs);
while(rs.next()){
System.out.print(rs.getInt(2));
System.out.println(rs.getString(1));
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
public void proselect(){
PreparedStatement pstmt=null;
Connection conn=null;
ResultSet rs=null;
conn=com.opendb.OpenDB.conn();//这个只是建立个连接
try {
pstmt = conn.prepareCall("call sel");//调用存储过程sel ,sel代码为select * from test
rs=pstmt.executeQuery();
System.out.println(rs);
while(rs.next()){
System.out.print(rs.getInt(2));
System.out.println(rs.getString(1));
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询