jsp页面:
<body background="../img/73134057724_副本.jpg"><br /><br />
<html:form action="/doSoldProductSelect" method="post">
<table border="1" width="300">
<tr><td>出售时间</td><td><html:text property="ptime" /></td></tr>
<tr><td>顾客姓名</td><td><html:text property="customer"/></td></tr>
<tr><td>品牌</td><td><html:select property="bno">
<html:optionsCollection name="listBrand" label="option_label" value="option_value"/></html:select></td></tr>
</table>
<html:submit value="查询"/>
<input type="button" value="查看所有销售记录" onclick="window.location.href('showAllSoldProductInfo.do')">
</html:form>
</body>
获得品牌列表:
public class ShowSoldProductSelectAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
OptionDao dao=new OptionDao();
try {
ArrayList<OptionBean> listBrand=dao.getAllBrandInfo();
request.setAttribute("listBrand",listBrand );
return mapping.findForward("ok");
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
}
进行模糊查询:
public ArrayList<SoldProduct> soldProductSelectInfo(String ptime,String customer,String bno) throws SQLException{ OracleConn c=new OracleConn();
Connection conn=c.getConnection();
PreparedStatement p=conn.prepareStatement("select * from soldproduct where ptime=? or customer like '%?%' or bno=?");//可能是这有问题?
p.setString(1, ptime);
p.setString(2, customer);
p.setString(3, bno);
ResultSet rs=p.executeQuery();
ArrayList<SoldProduct> list=new ArrayList<SoldProduct>();
while(rs.next()){
SoldProduct s=new SoldProduct();
s.setPno(rs.getString("pno"));
s.setBno(rs.getString("bno"));
s.setPtype(rs.getString("ptype"));
s.setPnum(rs.getString("pnum"));
s.setPrice(rs.getString("price"));
s.setPtime(rs.getString("ptime"));
s.setCustomer(rs.getString("customer"));
s.setPserver(rs.getString("pserver"));
list.add(s);
}
return list;
}
显示模糊查询结果:
<body>
<logic:present name="listSelect" scope="request">
<logic:empty name="listSelect" scope="request">销售记录为空</logic:empty>
<logic:notEmpty name="listSelect" scope="request">
<h2 align="center">销售记录表</h2>
<table width="68%" border="0" cellspacing="1" cellpadding="0" bgcolor="#000000" align="center">
<tr align="center">
<th width="85" height="25" bgcolor="#FFFFFF" align="center">商品编号</th>
<th width="40" bgcolor="#FFFFFF">品牌</th>
<th width="40" bgcolor="#FFFFFF"> 型号</th>
<th width="85" bgcolor="#FFFFFF"> 购买数量</th>
<th width="40" bgcolor="#FFFFFF">价格</th>
<th width="85"bgcolor="#FFFFFF"> 出售时间</th>
<th width="85" bgcolor="#FFFFFF">销售员</th>
<th width="85" bgcolor="#FFFFFF">顾客姓名</th>
<th width="40" bgcolor="#FFFFFF">更新</th>
<th width="40" bgcolor="#FFFFFF">删除</th>
</tr>
<logic:iterate id="element" name="listSelect"> <tr bgcolor="#FFFFFF" >
<td bgcolor="#FFFFFF"> <bean:write name="element" property="pno" /></td>
<td> <bean:write name="element" property="bno" /></td>
<td><bean:write name="element" property="ptype" /></td>
<td> <bean:write name="element" property="pnum" /></td>
<td> <bean:write name="element" property="price" /></td>
<td> <bean:write name="element" property="ptime" /></td>
<td> <bean:write name="element" property="pserver" /></td>
<td> <bean:write name="element" property="customer" /></td>
<td><a href="/MarketStruts/updateSoldProduct.do?pno=<bean:write name="element" property="pno"/>">更新</a></td>
<td><a href="/MarketStruts/deleteSoldProduct.do?pno=<bean:write name="element" property="pno" />" onclick="return confirm('是否确认删除?')">删除</a></td>
</tr>
</logic:iterate></table>
</logic:notEmpty>
</logic:present>
</body>
为什么会出现无效的列索引的错误呢,帮帮忙啊大虾们,感激不尽
<body background="../img/73134057724_副本.jpg"><br /><br />
<html:form action="/doSoldProductSelect" method="post">
<table border="1" width="300">
<tr><td>出售时间</td><td><html:text property="ptime" /></td></tr>
<tr><td>顾客姓名</td><td><html:text property="customer"/></td></tr>
<tr><td>品牌</td><td><html:select property="bno">
<html:optionsCollection name="listBrand" label="option_label" value="option_value"/></html:select></td></tr>
</table>
<html:submit value="查询"/>
<input type="button" value="查看所有销售记录" onclick="window.location.href('showAllSoldProductInfo.do')">
</html:form>
</body>
获得品牌列表:
public class ShowSoldProductSelectAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
OptionDao dao=new OptionDao();
try {
ArrayList<OptionBean> listBrand=dao.getAllBrandInfo();
request.setAttribute("listBrand",listBrand );
return mapping.findForward("ok");
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
}
进行模糊查询:
public ArrayList<SoldProduct> soldProductSelectInfo(String ptime,String customer,String bno) throws SQLException{ OracleConn c=new OracleConn();
Connection conn=c.getConnection();
PreparedStatement p=conn.prepareStatement("select * from soldproduct where ptime=? or customer like '%?%' or bno=?");//可能是这有问题?
p.setString(1, ptime);
p.setString(2, customer);
p.setString(3, bno);
ResultSet rs=p.executeQuery();
ArrayList<SoldProduct> list=new ArrayList<SoldProduct>();
while(rs.next()){
SoldProduct s=new SoldProduct();
s.setPno(rs.getString("pno"));
s.setBno(rs.getString("bno"));
s.setPtype(rs.getString("ptype"));
s.setPnum(rs.getString("pnum"));
s.setPrice(rs.getString("price"));
s.setPtime(rs.getString("ptime"));
s.setCustomer(rs.getString("customer"));
s.setPserver(rs.getString("pserver"));
list.add(s);
}
return list;
}
显示模糊查询结果:
<body>
<logic:present name="listSelect" scope="request">
<logic:empty name="listSelect" scope="request">销售记录为空</logic:empty>
<logic:notEmpty name="listSelect" scope="request">
<h2 align="center">销售记录表</h2>
<table width="68%" border="0" cellspacing="1" cellpadding="0" bgcolor="#000000" align="center">
<tr align="center">
<th width="85" height="25" bgcolor="#FFFFFF" align="center">商品编号</th>
<th width="40" bgcolor="#FFFFFF">品牌</th>
<th width="40" bgcolor="#FFFFFF"> 型号</th>
<th width="85" bgcolor="#FFFFFF"> 购买数量</th>
<th width="40" bgcolor="#FFFFFF">价格</th>
<th width="85"bgcolor="#FFFFFF"> 出售时间</th>
<th width="85" bgcolor="#FFFFFF">销售员</th>
<th width="85" bgcolor="#FFFFFF">顾客姓名</th>
<th width="40" bgcolor="#FFFFFF">更新</th>
<th width="40" bgcolor="#FFFFFF">删除</th>
</tr>
<logic:iterate id="element" name="listSelect"> <tr bgcolor="#FFFFFF" >
<td bgcolor="#FFFFFF"> <bean:write name="element" property="pno" /></td>
<td> <bean:write name="element" property="bno" /></td>
<td><bean:write name="element" property="ptype" /></td>
<td> <bean:write name="element" property="pnum" /></td>
<td> <bean:write name="element" property="price" /></td>
<td> <bean:write name="element" property="ptime" /></td>
<td> <bean:write name="element" property="pserver" /></td>
<td> <bean:write name="element" property="customer" /></td>
<td><a href="/MarketStruts/updateSoldProduct.do?pno=<bean:write name="element" property="pno"/>">更新</a></td>
<td><a href="/MarketStruts/deleteSoldProduct.do?pno=<bean:write name="element" property="pno" />" onclick="return confirm('是否确认删除?')">删除</a></td>
</tr>
</logic:iterate></table>
</logic:notEmpty>
</logic:present>
</body>
为什么会出现无效的列索引的错误呢,帮帮忙啊大虾们,感激不尽
SELECT t.index_name, t.status
FROM user_indexes t
WHERE t.table_name = upper('soldproduct');--2、如果状态为valid表示有效,而unusable表示无效,需要重建。
alter index 索引名 rebuild;
--一种方法就是查看建立在表字段上的索引是否有效,如果无效则重建
select index_name,status
from user_indexes
where table_name='SOLDPRODUCT';
--重建有两种方法,
--1.将已经建立好的无效索引重建
alter index indx_name rebuild;
--2.删除无效索引,重新建立
drop index index_name;
create index index_name
on soldproduct(bno)--customer or ptime
[tablespace users];更多关于索引的操作,请参考:
oracle 索引介绍
你可以直接把sql语句在数据库中运行一下试试就知道了。仔细检查你的代码吧,取结果集的时间。