我的主数据表大楷有100多万,查询速度还可以,可当我操作下面的语句时,若rs的结果小的时候(20~50条),程序可以正常操作成功,可当数据量超过100条时,程序报错:
Sp_down="select hk1.hw_id,hk1.isbn,hk1.pifa,hk1.hw_name "+Sp_down;
rs=mdb.executeQuery(Sp_down);
while(rs.next())
{
hw_id11=rs.getString("hw_id");
hw_cashs=rs.getString("pifa");
hw_name=rs.getString("hw_name");
isbn=rs.getString("isbn");
sql="select basket_id,hw_id,basket_count from basket1 where hw_id="+hw_id11+" and user_name='"+user_name+"' and basket_check='False'";
rs1=mdb.executeQuery(sql);
if(!rs1.next())
{
sql="insert into basket1 (hw_id,isbn,user_name,basket_count,hw_name,hw_cash,basket_date)";
sql=sql+"values("+hw_id11+",'"+isbn+"','"+user_name+"','"+book_sum+"','"+hw_name+"','"+hw_cashs+"','"+dat1+"')";
mdb.executeInsert(sql);
}
else
{
rs1.previous();
basket_count="0";
if(rs1.next())
{
basket_count=rs1.getString("basket_count");
}
count=Cint(basket_count);
count=count+Cint(book_sum);
String sql2="update basket1 set basket_count='"+Integer.toString(count)+"' where basket_id="+rs1.getString("basket_id");
mdb.executeUpdate(sql2);
}
}
Sp_down="select hk1.hw_id,hk1.isbn,hk1.pifa,hk1.hw_name "+Sp_down;
rs=mdb.executeQuery(Sp_down);
while(rs.next())
{
hw_id11=rs.getString("hw_id");
hw_cashs=rs.getString("pifa");
hw_name=rs.getString("hw_name");
isbn=rs.getString("isbn");
sql="select basket_id,hw_id,basket_count from basket1 where hw_id="+hw_id11+" and user_name='"+user_name+"' and basket_check='False'";
rs1=mdb.executeQuery(sql);
if(!rs1.next())
{
sql="insert into basket1 (hw_id,isbn,user_name,basket_count,hw_name,hw_cash,basket_date)";
sql=sql+"values("+hw_id11+",'"+isbn+"','"+user_name+"','"+book_sum+"','"+hw_name+"','"+hw_cashs+"','"+dat1+"')";
mdb.executeInsert(sql);
}
else
{
rs1.previous();
basket_count="0";
if(rs1.next())
{
basket_count=rs1.getString("basket_count");
}
count=Cint(basket_count);
count=count+Cint(book_sum);
String sql2="update basket1 set basket_count='"+Integer.toString(count)+"' where basket_id="+rs1.getString("basket_id");
mdb.executeUpdate(sql2);
}
}
Sp_down="select hw1.hw_id "+Sp_down;
rs=mdb.executeQuery(Sp_down);
while(rs.next())
{
hw_id11=rs.getString("hw_id");
sql="insert into d_basket1(hw_id,user_name,basket_date)";
sql=sql+"values("+hw_id11+",'"+user_name+"','"+dat1+"')";
mdb.executeInsert(sql);
}
为什么啊?
是不是你执行过程中的某个sql语句遇到问题呢?
比如插入的主键重复之类的.还是闲看看报错信息把
Sp_down="select hk1.hw_id "+Sp_down;
rs=mdb.executeQuery(Sp_down);
while(rs.next())
{
hw_id11=rs.getString("hw_id");
sql="insert into d_basket1(hw_id,user_name,basket_date)";
sql=sql+"values("+hw_id11+",'"+user_name+"','"+dat1+"')";
mdb.executeInsert(sql);
}
exception org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
sun.reflect.GeneratedMethodAccessor679.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:239)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:266)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:157)
root cause java.lang.NullPointerException
org.apache.jsp.BA_005fChangeStdData_jsp._jspService(BA_005fChangeStdData_jsp.java:127)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
sun.reflect.GeneratedMethodAccessor679.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:239)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:266)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:157)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.27 logs.
--------------------------------------------------------------------------------Apache Tomcat/5.0.27
楼主把你插入的数据给打印出来,呵呵。可以看的更清楚些
大量的数据估计中间有的是非法的
Sp_down="select hk1.hw_id "+Sp_down;
rs=mdb.executeQuery(Sp_down);
while(rs.next())
{
hw_id11=rs.getString("hw_id");
sql="insert into d_basket1(hw_id,user_name,basket_date)";
sql=sql+"values("+hw_id11+",'"+user_name+"','"+dat1+"')";
mdb.executeInsert(sql);
}