以下是我的代码,ACCESS数据库放于SRC文件下
package del;
import java.sql.*;
public class DBHelper {
public static Connection getCon()
{
// JDBC驱动
String classname = "sun.jdbc.odbc.JdbcOdbcDriver";
// 数据库地址
String URL = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+DBHelper.class.getResourceasstream("/album.mdb")+""; //我要的是access的相对路径
//数据库连接对象
Connection conn=null;
try {
// 加载JDBC驱动
Class.forName(classname);
// 连接数据库
conn = DriverManager.getConnection(URL);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
} }
运行时出现这样的异常
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# EXCEPTION_ACCESS_VIOLATION () (0xc0000005) at pc=0x00490064,pid=644,tid=700
#
# Java VM:java HotSpot(TM) Client VM (1.5.0._11-b03 mixed mode)
# Problematic frame:
# C 0x00490064
#
# An error report file with more information is saved as hs_err_pid644.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
package del;
import java.sql.*;
public class DBHelper {
public static Connection getCon()
{
// JDBC驱动
String classname = "sun.jdbc.odbc.JdbcOdbcDriver";
// 数据库地址
String URL = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+DBHelper.class.getResourceasstream("/album.mdb")+""; //我要的是access的相对路径
//数据库连接对象
Connection conn=null;
try {
// 加载JDBC驱动
Class.forName(classname);
// 连接数据库
conn = DriverManager.getConnection(URL);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
} }
运行时出现这样的异常
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# EXCEPTION_ACCESS_VIOLATION () (0xc0000005) at pc=0x00490064,pid=644,tid=700
#
# Java VM:java HotSpot(TM) Client VM (1.5.0._11-b03 mixed mode)
# Problematic frame:
# C 0x00490064
#
# An error report file with more information is saved as hs_err_pid644.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
解决方案 »
- 求一本以实例讲解适合初学者学习的java web书
- 不显示删除回复显示所有回复显示星级回复显示得分回复 Hibernate正向工程生成oracle数据库,ORA-02275: 此表中已经存在这样的引用约束条件[
- 求教,关于struts2的debug标签的问题
- jsf超难的问题,再现等
- 关于Tomcat无法启动的问题,谢谢了
- Resin 自定义标记(Custom Tag) 烦人
- 请教:jsp页面中用文本方式获得yyyy-mm-dd格式的日期如何判断格式正确性
- 请教JSP中 hidden传值问题....
- Tomcat + ACCESS 多线程 支持否????
- Jsp 问题求解!急!
- 基于ext开发的一套自动采集软件,欢迎大家提意见。
- struts.xml配置的代码,谁能帮忙分析一下
If you would like to submit a bug report, please visit:
http://java.sun.com/webapps/bugreport/crash.jsp是虚拟机的问题吗?