JDBC连接Oracle数据库问题

hhb2009sunny hhb2009sunny 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我在使用JDBC连接数据库,调试时出现如上所示
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开发,希望大家可以帮我一下。
...全文

相关推荐

评论 8
收藏 已收藏
分享
返回顶部
hhb2009sunny
Java EE 67,535 成员 225,843 内容