我的程序在执行此语句时遇到致命错误,就像循环第二次执行此语句Statement stmt = conn.createStatement();
一样。是什么原因造成的?是否不允许通过方法传递连接?程序运行通过这个循环:
Connection conn = open_connection();
for(int aa = 0;aa<symbols.length;aa++){
String[][] dub_array = parse(symbols[aa]);
autowave(dub_array,19,14,symbols[aa],conn);
}
open_connection看起来像这样:
public static Connection open_connection() throws Exception{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String sDBQ = "C:/Documents and Settings/mike/Desktop/stock/data/AW.mdb";
String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" + sDBQ + ";DriverID=22;READONLY=false";
Connection conn = DriverManager.getConnection( database ,"","");
return conn;
}
错误如下:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c90100b, pid=3584, tid=8668
#
# JRE version: 7.0_02-b13
# Java VM: Java HotSpot(TM) Client VM (22.0-b10 mixed mode, sharing windows-x86 )
# Problematic frame:
# C [ntdll.dll+0x100b]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:Documents and SettingsmikeDesktopstockstockhs_err_pid3584.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
我的程序在像第二次循环执行此语句语句stmt=conn.createStatement();autowave(dub_array,19,14,symbol[aa],conn);尝试在循环之前只创建一个语句对象,然后在循环中使用它。带有MS Access的JdbcOdbcDriver是蹩脚的,有时会遇到意外问题。