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>


没出现应有的值,感觉还是存储过程的问题。请教一下!
...全文
86 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
sxl6159078 2004-11-16
  • 打赏
  • 举报
回复
up

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧