出现的错误信息:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] 找不到文件 '(未知)'
代码如下:
<%@ page contentType="text/html; charset=GB18030" %>
<%@page import="java.sql.*" %>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){
out.print("数据库驱动程序装入错误");
}
try{
String url="jdbc:odbc:driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ="+request.getRealPath("/")+"db_database.mdb";
Connection conn=DriverManager.getConnection(url);
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("SELECT * FROM tb_user");
while(rs.next()){
out.print(rs.getInt("ID")+" ");
out.print(rs.getString("username")+" ");
out.print(rs.getString("password")+" ");
out.println("
");
}
rs.close();
stmt.close();
conn.close();
}
catch(Exception ex){
out.print(ex);
}
%>