我在列表中有一些值,我希望将它与存储在数据库中的值进行比较,当我在while循环期间从数据库中获取数据时,我使用for循环来获取列表值 但之后我的数据库数据将不再显示如果我删除for循环的代码,db数据显示我在哪里做错了请帮助
<%
try{
String emi=request.getParameter("emi");
imei=emi;
String month=request.getParameter("month");
String day=request.getParameter("dt");
String year=request.getParameter("year");
String month1=request.getParameter("month1");
String day1=request.getParameter("dt1");
String year1=request.getParameter("year1");
String date =month+" "+day+" "+year;
String date1=month1+" "+day1+" "+year1;
System.out.println(date);
System.out.println(date1);
Connection con = history.show.getConnection();
PreparedStatement ps = con.prepareStatement("select * from sms where s_imei='"+emi+"' and sms_date between '"+date+"' and '"+date1+"'");
ResultSet rs = ps.executeQuery();
officialNumber num=new officialNumber();
ofcNumbers=num.checkNumber();
System.out.println("List size" +ofcNumbers.size());
while(rs.next())
{
for(int i=0;i<=ofcNumbers.size();i++)
{
String n = ofcNumbers.get(i);
}
%>
<tr>
<td>
<%= rs.getString("sms_phoneNumber")%>
<td>
<%= rs.getString("sms_personName")%>
<td>
<%= rs.getString("sms_type")%>
<td>
<%= rs.getString("sms_date")%>
<td>
<%= rs.getString("sms_Time")%>
<td>
<%= rs.getString("s_logType")%>
</tr>
<tr class="alt" >
<td class="alt" colspan="6" >
<%= rs.getString("sms_body")%>
<%
} //end of while
} //end of try
catch(Exception e){}
%>
officialNumber类只是用数据填充列表
public class officialNumber {
List<String> ofcNumbers= new ArrayList<String>();
String listNumber;
// Connection con1 = history.show.getConnection();
public List checkNumber()
{
Connection con = null;
PreparedStatement ps = null;
try
{
con = getConnection();
ps = con.prepareStatement("select * from ofcNumbers");
ResultSet rs = ps.executeQuery();
System.out.println("before while loop") ;
while ( rs.next())
{
System.out.println("after while loop") ;
listNumber=rs.getString("phone_number");
ofcNumbers.add(listNumber);
System.out.println("first list size"+ofcNumbers.size()) ;
}
rs.close();
ps.close();
con.close();
}
catch(Exception ex)
{
System.out.println( ex.getMessage());
}
finally
{
//clean(con,ps);
}
return ofcNumbers;
}
}