jsp问题如何解决?!

来源:互联网 发布:梁朝伟 帅 知乎 编辑:程序博客网 时间:2024/04/28 07:20

老师让做一个小型的个人理财系统,用这学期学的jsp做。因为项目比较小,所以我用jsp+javabean.

前面分析的都很顺利,到后面的时候就出问题了,报了个这样的错误。强行关闭我的tomcat。

  1. #  
  2. # An unexpected error has been detected by Java Runtime Environment:  
  3. #  
  4. #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c92100bpid=2360tid=1300 
  5. #  
  6. # Java VM: Java HotSpot(TM) Client VM (11.3-b02 mixed mode windows-x86)  
  7. # Problematic frame:  
  8. # C  [ntdll.dll+0x100b]  
  9. #  
  10. # An error report file with more information is saved as:  
  11. # D:/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_8.5.0.me201003121946/tomcat/bin/hs_err_pid2360.log  
  12. #  
  13. # If you would like to submit a bug report, please visit:  
  14. #   http://java.sun.com/webapps/bugreport/crash.jsp  
  15. # The crash happened outside the Java Virtual Machine in native code.  
  16. # See problematic frame for where to report the bug.  
  17. #  

有关的代码是这样的:

1.数据库操作类

  1. /**  
  2.  * 操作支出表的实体bean  
  3.  */ 
  4. package com.hb.Dao;  
  5.  
  6. import java.sql.Connection;  
  7. import java.sql.PreparedStatement;  
  8. import java.sql.ResultSet;  
  9.  
  10. /**  
  11.  * @author icecold  
  12.  *   
  13.  */ 
  14. public class OutDao {  
  15.     java.sql.Connection conn = null;  
  16.     java.sql.PreparedStatement ps = null;  
  17.     java.sql.ResultSet rs = null;  
  18.     java.sql.Statement stmt = null;  
  19.     String sql = "";  
  20.     /*  
  21.      * 判断是否存在重复id  
  22.      */ 
  23.     public boolean isOutExist(String id){  
  24.         conn=DatabaseUtil.getConnection();  
  25.         String sql="select *from out where id=?";  
  26.         try{  
  27.             PreparedStatement ps=conn.prepareStatement(sql);  
  28.             ps.setString(1, id);  
  29.             ResultSet rs=ps.executeQuery();  
  30.             if(rs.next()){  
  31.                 //此id重复  
  32.                 return true;  
  33.             }  
  34.             rs.close();  
  35.             ps.close();  
  36.         }catch(Exception e){  
  37.             e.printStackTrace();  
  38.         }finally{  
  39.             DatabaseUtil.closeConnection(conn);  
  40.         }  
  41.         return false;  
  42.     }  
  43.       
  44.     /*  
  45.      * 增加记录  
  46.      */ 
  47.     public boolean insertOut(String id, String name, String type,  
  48.             java.sql.Date date, double money, String beizhu) {  
  49.         boolean flag = false;  
  50.         int n = 0;  
  51.         sql = "insert into out values(?,?,?,?,?,?)";  
  52.         try {  
  53.             ps = conn.prepareStatement(sql);  
  54.             ps.setString(1, id);  
  55.             ps.setString(2, name);  
  56.             ps.setString(3, type);  
  57.             ps.setDate(4, date);  
  58.             ps.setDouble(5, money);  
  59.             ps.setString(6, beizhu);  
  60.             n = ps.executeUpdate();  
  61.             if (n > 0) {  
  62.                 flag = true;  
  63.             } else {  
  64.                 flag = false;  
  65.             }  
  66.             ps.close();  
  67.  
  68.         } catch (Exception e) {  
  69.             e.printStackTrace();  
  70.         } finally {  
  71.             try {  
  72.                 conn.close();  
  73.             } catch (Exception e) {  
  74.                 e.printStackTrace();  
  75.             }  
  76.         }  
  77.         return flag;  
  78.     }  
  79.       
  80. }  

2、调用Javabean操作数据库的jsp文件代码:

 

  1. if (outDao.isOutExist(id)) {  
  2.                     out.println("<script language='javascript'>alert('此编号已存在,请更换后添加!');</script>");  
  3.                 } else {  
  4.                     //if(outDao.insertOut(myOut.getId(),myOut.getName(),myOut.getType(),myOut.getDate(),myOut.getMoney(),myOut.getBeizhu())){  
  5.                         response.sendRedirect("outMan.jsp");  
  6.                     //}  
  7.                       
  8.                 } 

上面的代码,我必须按照上面的那样把那两行注释掉,才能不强行关闭我的tomcat,网上搜了下,有人说是数据库操作的问题,暂时认为这个问题应该出在isOutExist和insertOut两个之间。

求高手!!!

 

原创粉丝点击