jsp+javabean+存储过程 问题!

egfly 2004-08-25 11:37:48
存储过程:
create or replace procedure ptdqkc(i_blstor in char) as
l_name char(30);
l_pdid char(6);
l_kc number(8);
cursor region_cur is
select pdid,price,num from in_stor where blstor=i_blstor;
begin
open region_cur;
fetch region_cur into l_name,l_pdid,l_kc;
close region_cur;
end;

javabean文件:
package tryexp.pro.bean;

import java.io.*;
import java.sql.*;
import java.util.*;
import javax.sql.*;
import javax.naming.*;

public class insertPro implements java.io.Serializable{

public insertPro(){
}


public Hashtable dqkc() throws SQLException{
int j = 0;
Connection con = null;
CallableStatement proc = null;
String s3="";
Hashtable hashtable1 = new Hashtable();
try {
javax.sql.DataSource myDataSource = null;
Context ctx = null;
try {
ctx = new InitialContext();
myDataSource = (javax.sql.DataSource)ctx.lookup("wldatesource");
con = myDataSource.getConnection();
proc = con.prepareCall("{ call ptdqkc(?) }");
proc.setString(1, "2");
ResultSet rs = proc.executeQuery();
rs.last();
j=rs.getRow();
rs.first();
for(int i = 0; i < j; i++)
{
String s4 = rs.getString(1);
String s5 = rs.getString(2);
String s6 = rs.getString(3);
s3 = s3 + "<tr align=center>";
s3 = s3 + "<td color=#0000FF>" + s4 + "</td>";
s3 = s3 + "<td color=#0000FF>" + s5 + "</td>";
s3 = s3 + "<td color=#0000FF>" + s6 + "</td>";
s3 = s3 + "</tr>";
if(!rs.next())
break;
}
}
finally {
try {
proc.close();
}
catch (SQLException e) {}
con.close();
}
}
catch (Exception e){
System.out.print("Connection Failed" + e.getMessage());
}
hashtable1.put("RecordCount", String.valueOf(j));
hashtable1.put("HtmlStr", s3);
return hashtable1;
}

}

jsp文件:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%@ page contentType=“text/html; charset=gb2312“ %>
<%@ page errorpage="../Error.jsp" %>

<title>当前库存 </title>
</head>
<jsp:useBean id="insertPro" class="tryexp.pro.bean.insertPro" />
<%

Hashtable AOutParam = new Hashtable();
AOutParam = insertPro.dqkc();

%>
<body>
<H3>当前库存 </H3>
<center><hr>
<tr><td width="125" bgcolor="ccccff">商品总数:<%=AOutParam.get("RecordCount") %></td></tr>
<table >
<tr align="center">
<td bgcolor="#FFFFFF"> 商品名称 </td>
<td bgcolor="#FFFFFF"> 代码</td>
<td bgcolor="#FFFFFF"> 数量 </td>
</tr>
<tr><td><%=AOutParam.get("HtmlStr")%> </td></tr>


</form></table>

</body></html>


没出现应有的值,感觉还是存储过程的问题。请教一下!
...全文
64 点赞 收藏 1
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
sxl6159078 2004-11-16
up
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2004-08-25 11:37
社区公告
暂无公告