<%@ page language="java" contenttype="text/html;charset=gb2312" %>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%
string usernamev="";
string passwordv="";
try
{
//路径
string p=request.getservletpath();
string path=request.getrealpath(p);
path=path.substring(0,path.lastindexof(""));
string dbpath=path+"userdatabase.mdb";
string dbname="";
string user="";
//连接
access数据库的连接字符串
string url="jdbc:odbc:driver={microsoft access driver (*.mdb)};dbq="+dbpath;
//创建连接对象和statement对象。
class.forname("sun.jdbc.odbc.jdbcodbcdriver");
connection conn=drivermanager.getconnection(url);
statement stmt=conn.createstatement(resultset.type_scroll_sensitive,resultset.concur_updatable);
string sql="select * from userinformation";
resultset rs=stmt.executequery(sql);
while(rs.next())
{
usernamev=rs.getstring("username");
passwordv=rs.getstring("password
br>
// out.print("用户名:"+rs.getstring("username"));
out.print("用户名:"+usernamev+"<br>");
out.print("密码:"+passwordv);
}
rs.close();
stmt.close();
conn.close();
}
catch (exception e)
{//error
out.print("发生错误!");
}
%>