67,513
社区成员
发帖
与我相关
我的任务
分享
public ArrayList<Hashtable<String, String>> getList(String paramString) {
ArrayList<Hashtable<String, String>> localArrayList = new ArrayList<Hashtable<String, String>>();
try {
this.conn = getConnection();
this.stmt = this.conn.createStatement();
ResultSet localResultSet = this.stmt.executeQuery(paramString);
ResultSetMetaData localResultSetMetaData = localResultSet
.getMetaData();
int i = localResultSetMetaData.getColumnCount();
while (localResultSet.next()) {
Hashtable<String, String> localHashtable = new Hashtable<String, String>();
for (int j = 1; j <= i; ++j) {
String str1 = localResultSetMetaData.getColumnName(j);
String str2 = localResultSet.getString(j);
if (str2 == null)
str2 = "";
localHashtable.put(str1, str2);
}
localArrayList.add(localHashtable);
}
localResultSet.close();
this.stmt.close();
this.conn.close();
} catch (SQLException localSQLException) {
try {
this.stmt.close();
this.conn.close();
} catch (Exception localException) {
}
}
return localArrayList;
}
,就是在this.stmt = this.conn.createStatement();这句话处出错,调用数据库连接的页面代码如下:<%@page language="java" contentType="text/html;charset=gb2312"%>
<jsp:useBean id="db" class="xw.ConnDb" />
<jsp:useBean id="str" class="xw.StrManager" />
<jsp:useBean id="c_check" class="xw.ErrorCheck" />
<html>
<head>
<title>Cookie版 购物车</title>
<style type="text/css">
a {
font-size: 12px;
text-decoration: none;
}
table {font-size:12px;}
#shop{border:5px solid #ccc;}
@IMPORT url("Jash.css");
</style>
</head>
<body>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<%
java.util.ArrayList<java.util.Hashtable<String,String>> rs = new java.util.ArrayList<java.util.Hashtable<String,String>>();
rs = db.getList("select PRID,NAME,CONTENT,PIC,XID,DID,BPRICE,SPRICE from a2009_shuhua_product");
if (rs != null) {
java.util.Hashtable<String,String> hash = new java.util.Hashtable<String,String>();
for (int i = 0; i < rs.size(); i++) {
hash = rs.get(i);
String PRID = str.notEmpty(hash.get("PRID"));
String SPRICE = str.notEmpty(hash.get("SPRICE"));
String BPRICE = str.notEmpty(hash.get("BPRICE"));
String NAME = str.notEmpty(hash.get("NAME"));
String PIC = str.notEmpty(hash.get("PIC"));
%>
<%
if (i == 0) {
%>
<TR>
<%
}
%>
<%
if (i != 0 && i % 4 == 0) {
%>
</TR>
<TR>
<%
}
%>
<TD height=80>
<TABLE cellSpacing=1 cellPadding=2 width=155 align=center border=0>
<TBODY>
<TR>
<TD align=middle>
<A href="iteminfo.jsp?prid=<%=PRID%>" target=_blank><IMG
height=120 src="<%=PIC%>" width=120 border=0 id="shop">
</A>
</TD>
</TR>
<TR>
<TD>
<IMG style="CURSOR: hand"
onclick="centerNewWin('/iteminfo.jsp?prid=<%=PRID%>', '4444', 900, 650)"
src="images/icon_mag.gif" align=absMiddle>
<A href="iteminfo.jsp?prid=<%=PRID%>" target=_blank><%=NAME%></A>
<BR>
<SPAN class=red><BR>
<IMG src="images/icon_won.gif" align=absMiddle vspace=2> <%=SPRICE%>
<BR>
<IMG src="images/icon_point_s.gif" align=absMiddle vspace=2> <%=BPRICE%> <!--<img src="/images_china/icon_nointerest_s.gif" vspace="2" align="absmiddle"> 0 -->
</SPAN>
</TD>
</TR>
</TBODY>
</TABLE>
</TD>
<TD bgColor=#e3e3e3>
<IMG height=1 src="images/blank.gif" width=1>
</TD>
<%
if (i == 0 && i % 4 != 0) {
%>
<TD width=35>
</TD>
<%
}
%>
<%
hash = null;
}
hash = null;
}
rs = null;
%>
<TR>
<TD colSpan=8 height=10>
</TD>
</TR>
<TR>
<TD class=linetable width="100%" colSpan=8 height=1></TD>
</TR>
<TR>
<TD colSpan=8 height=10>
</TD>
</TR>
</TBODY>
</TABLE>
</body>
</html>
,大家有没有遇见过这种情况?大侠们,我是刚刚学习Java Web开发,希望大家可以帮我一下。