#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c921010, pid=684, tid=2000
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_03-b07 mixed mode)
# Problematic frame:
# C  [ntdll.dll+0x1010]
#
# An error report file with more information is saved as hs_err_pid684.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#
问题描述:调用一次还好  调用二次以上出现上面的错误文件有三个类  一个接口一个类DBMpublic class DBM{    public static PreparedStatement pstmt=null;
    private static Connection conn=null;
    public DBM(){}    //连接
    public static void openConn() {
        try {
            if (conn == null) {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                conn = DriverManager.getConnection("jdbc:odbc:Park",
                                                  "sa", "sa");
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }    //关闭连接
    public static void closeConnection() {
        try {
            if (conn != null) {
                conn.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }    }    //查询
    public static ResultSet dbQuery(String strSQL) {
        ResultSet rs = null;
        try {
            if (conn != null) {
                pstmt = conn.prepareStatement(strSQL);
                rs = pstmt.executeQuery();
            }
        } catch (SQLException sqle) {
            System.out.println("错误:" + sqle);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return rs;
    }    //添加
    public static int dbExecute(String strSQL) {
        int rowCount = 0;
        try {
            if (conn != null) {
                pstmt = conn.prepareStatement(strSQL);
                rowCount = pstmt.executeUpdate();
            }
        } catch (SQLException sqle) {
            System.out.println("添加错误:" + sqle);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return rowCount;
    }    //PreparedStatement断开
    public static void closeStatement() {
        try {
            if (pstmt != null) {
                pstmt.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }    //ResultSet断开
    public static void closeResultSet(ResultSet rs) {
        try {
            rs.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
一个类DeskBean
public class DeskBean {
    private String desk_id;
    private String title;
    private String path;
    private String author;
    private String createtime;
    //Get和Set属性
}
一个类DeskDAO 实现Idesk
public ArrayList sel_All_desks() {
        String sql="select * from DESKTOP";
        ArrayList arrayList=new ArrayList();
        try
        {
                DBM.openConn();
                ResultSet rs=DBM.dbQuery(sql);
                while(rs.next())
                {
                        DeskBean bean=new DeskBean();
                        bean.setDesk_id(rs.getLong(1)+"");
                        bean.setTitle(rs.getString(2).trim());
                        bean.setPath(rs.getString(3).trim());
                        bean.setAuthor(rs.getString(4).trim());
                        bean.setCreatetime(rs.getString(5).trim());
                        arrayList.add(bean);
                }
                rs.close();
                DBM.closeStatement();
        }catch(Exception ex)
        {
                ex.printStackTrace();
        }finally
        {
            DBM.closeConnection();
        }
        return arrayList;
    }
接口Idesk
public ArrayList sel_All_desks();

解决方案 »

  1.   

    n unexpected error has been detected by HotSpot Virtual Machine:没别的方法,升级你的JDK版本, 1.5好像都到了 11 了吧!你去看看!
      

  2.   

    创建了实现类    public static void main(String[] args) {
           Idesk io=new DeskDAO();
            for(int j=0;j<2;j++) {
                    ArrayList array = io.sel_All_desks() 
                    if (array != null) {
                        for (int i = 0; i < array.size(); i++) {
                            DeskBean obj = (DeskBean) array.get(i);
                            System.out.println(obj.getNew_id() + "," + obj.getTitle() +
                                               "," +
                                               obj.getTest() + "," + obj.getAuthor() +
                                               "," +
                                               obj.getCreatetime());
                        }
                    }
            }
        }竟然出错了  否则 用在servlet之下  点击一下 就出现错  点击二下 tomcat当场关闭
      

  3.   

    我用的是JBuilder2006   用的是tomcat5.5  JDK应该是1.5的
      

  4.   

    jdk-1_5_0_16-windows-i586-p.exe更新到这个版本,如果有更新,用最新的
      

  5.   

    呵呵  经过调试  到最后才发现   Connection 不要被判断。是否为null  。。