有这么一个程序,连接数据库时总是有问题。用的是tomcat4.1做服务器连接Access数据库
JAVA程序
package zcc;
import java.io.*;
import java.sql.*;
import java.util.*;
public class jdbc {
Connection conn = null ;
public java.sql.Connection ConnectDB(){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
conn= DriverManager.getConnection("jdbc:odbc:zcc","zcc","zcc");
}
catch(Exception e){
}
return this.conn ;
}
}
JSP程序
<%@page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,java.util.*" %>
<jsp:useBean id="jdbc" scope="application" class="zcc.jdbc"/>
<html>
<head>
<title>检查</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel='stylesheet' type='text/css' href='inc/TURBOCRM.CSS'>
</head>
<body>
<center>
检查
<%
Connection con=jdbc.ConnectDB();
java.sql.Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
// String sql="Update 用户 set 密码='123' where 用户='zcc'";
// stmt.executeUpdate(sql);
String sql="SELECT * FROM 用户";
ResultSet rs=stmt.executeQuery(sql);
</center>
</body>
</html>
错误信息是:
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x6D366658
Function=[Unknown.]
Library=c:\java\jre\bin\client\jvm.dll
NOTE: We are unable to locate the function name symbol for the error
just occurred. Please refer to release documentation for possible
reason and solutions.
Current Java thread:
at sun.jdbc.odbc.JdbcOdbc.setStmtAttrPtr(Native Method)
at sun.jdbc.odbc.JdbcOdbc.SQLSetStmtAttrPtr(JdbcOdbc.java:4676)
at sun.jdbc.odbc.JdbcOdbcResultSet.setRowStatusPtr(JdbcOdbcResultSet.jav
a:4473)
at sun.jdbc.odbc.JdbcOdbcResultSet.initialize(JdbcOdbcResultSet.java:171
)
at sun.jdbc.odbc.JdbcOdbcStatement.getResultSet(JdbcOdbcStatement.java:4
23)
- locked <02A70830> (a sun.jdbc.odbc.JdbcOdbcStatement)
at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:2
53)
at zcc._0002fzcc_0002fcheck_0002ejspcheck_jsp_21._jspService(_0002fzcc_0
002fcheck_0002ejspcheck_jsp_21.java:98)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspSer
vlet.java:177)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
18)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:4
04)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372
)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.
java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743
)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnectio
n(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:
416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java
:498)
at java.lang.Thread.run(Thread.java:536)
Dynamic libraries:
0x00400000 - 0x00406000 c:\java\bin\java.exe
0x7C920000 - 0x7C9B4000 C:\WINDOWS\system32\ntdll.dll
0x7C800000 - 0x7C91C000 C:\WINDOWS\system32\kernel32.dll
0x77DA0000 - 0x77E49000 C:\WINDOWS\system32\ADVAPI32.dll
0x77E50000 - 0x77EE1000 C:\WINDOWS\system32\RPCRT4.dll
0x77BE0000 - 0x77C38000 C:\WINDOWS\system32\MSVCRT.dll
0x6D330000 - 0x6D445000 c:\java\jre\bin\client\jvm.dll
0x77D10000 - 0x77D9F000 C:\WINDOWS\system32\USER32.dll
0x77EF0000 - 0x77F37000 C:\WINDOWS\system32\GDI32.dll
0x76B10000 - 0x76B3A000 C:\WINDOWS\system32\WINMM.dll
0x76300000 - 0x7631D000 C:\WINDOWS\system32\IMM32.DLL
0x62C20000 - 0x62C29000 C:\WINDOWS\system32\LPK.DLL
0x73FA0000 - 0x7400B000 C:\WINDOWS\system32\USP10.dll
0x6D1D0000 - 0x6D1D7000 c:\java\jre\bin\hpi.dll
0x6D300000 - 0x6D30D000 c:\java\jre\bin\verify.dll
0x6D210000 - 0x6D228000 c:\java\jre\bin\java.dll
0x6D320000 - 0x6D32D000 c:\java\jre\bin\zip.dll
0x6D2D0000 - 0x6D2DD000 C:\java\jre\bin\net.dll
0x71A40000 - 0x71A4B000 C:\WINDOWS\system32\WSOCK32.dll
0x71A20000 - 0x71A37000 C:\WINDOWS\system32\WS2_32.dll
0x71A10000 - 0x71A18000 C:\WINDOWS\system32\WS2HELP.dll
0x719C0000 - 0x719FE000 C:\WINDOWS\system32\mswsock.dll
0x60FD0000 - 0x61025000 C:\WINDOWS\system32\hnetcfg.dll
0x71A00000 - 0x71A08000 C:\WINDOWS\System32\wshtcpip.dll
0x76EF0000 - 0x76F17000 C:\WINDOWS\system32\DNSAPI.dll
0x76D30000 - 0x76D48000 C:\WINDOWS\system32\iphlpapi.dll
0x76F80000 - 0x76F88000 C:\WINDOWS\System32\winrnr.dll
0x76F30000 - 0x76F5C000 C:\WINDOWS\system32\WLDAP32.dll
0x76F90000 - 0x76F96000 C:\WINDOWS\system32\rasadhlp.dll
0x6D250000 - 0x6D25A000 C:\java\jre\bin\JdbcOdbc.dll
0x73540000 - 0x7357D000 C:\WINDOWS\system32\ODBC32.dll
0x5D170000 - 0x5D207000 C:\WINDOWS\system32\COMCTL32.dll
0x7D590000 - 0x7DD82000 C:\WINDOWS\system32\SHELL32.dll
0x77F40000 - 0x77FB6000 C:\WINDOWS\system32\SHLWAPI.dll
0x76320000 - 0x76367000 C:\WINDOWS\system32\comdlg32.dll
0x77180000 - 0x77282000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-C
ontrols_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll
0x20000000 - 0x20017000 C:\WINDOWS\system32\odbcint.dll
0x4AAC0000 - 0x4AB04000 C:\WINDOWS\system32\odbcjt32.dll
0x1B000000 - 0x1B170000 C:\WINDOWS\system32\msjet40.dll
0x1B5D0000 - 0x1B665000 C:\WINDOWS\system32\mswstr10.dll
0x76990000 - 0x76ACD000 C:\WINDOWS\system32\ole32.dll
0x770F0000 - 0x7717C000 C:\WINDOWS\system32\OLEAUT32.dll
0x4B4E0000 - 0x4B4EE000 C:\WINDOWS\system32\odbcji32.dll
0x1B2C0000 - 0x1B2CD000 C:\WINDOWS\system32\msjter40.dll
0x1B2D0000 - 0x1B2F6000 C:\WINDOWS\system32\MSJINT40.DLL
0x77FC0000 - 0x77FD1000 C:\WINDOWS\system32\Secur32.dll
0x76FA0000 - 0x7701F000 C:\WINDOWS\system32\CLBCATQ.DLL
0x77020000 - 0x770BA000 C:\WINDOWS\system32\COMRes.dll
0x77BD0000 - 0x77BD8000 C:\WINDOWS\system32\VERSION.dll
0x1B810000 - 0x1B84A000 C:\WINDOWS\system32\msjtes40.dll
0x0B690000 - 0x0B69B000 C:\WINDOWS\system32\VBAJET32.DLL
0x0BE40000 - 0x0BEA2000 C:\WINDOWS\system32\expsrv.dll
0x5ADC0000 - 0x5ADF7000 C:\WINDOWS\system32\uxtheme.dll
0x76C60000 - 0x76C88000 C:\WINDOWS\system32\imagehlp.dll
0x68D60000 - 0x68E01000 C:\WINDOWS\system32\DBGHELP.dll
0x76BC0000 - 0x76BCB000 C:\WINDOWS\system32\PSAPI.DLL
Local Time = Thu Sep 20 09:56:28 2007
Elapsed Time = 8
#
# HotSpot Virtual Machine Error : EXCEPTION_ACCESS_VIOLATION
# Error ID : 4F530E43505002D5
# Please report this error at
# http://java.sun.com/cgi-bin/bugreport.cgi
#
# Java VM: Java HotSpot(TM) Client VM (1.4.0_01-b03 mixed mode)
#
# An error report file has been saved as hs_err_pid3260.log.
# Please refer to the file for further information.
#
一句一句的测试,发现是rs=stmt.executeQuery(sql);的问题。如果将
String sql="SELECT * FROM 用户";
ResultSet rs=stmt.executeQuery(sql);
删除,换上executeUpdate那2句,就完全没问题,能正常运行。
还请高手看一下啊。实在搞不懂了。是什么问题