请教!jsp连接数据库问题,谁能帮我啊
deane 2005-09-18 11:23:38 作为初次连接,我选择简单的Access,用odbc,现在的问题是运行的时候总提示错误,也就是连接不上,
而相同的代码我在Java里测试却又好使!这是怎么回事?
<%@ page import="java.sql.*"%>
<%@ page contentType="text/html;charset=gb2312"%>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(Exception e){
out.println("驱动不");
}
try{
Connection conn=DriverManager.getConnection("jdbc:odbc:mima");
Statement stmt=conn.createStatement();
ResultSet rst=stmt.executeQuery("select * from user where password='111'");
if (rst.next()){
stmt.close();
conn.close();
out.println("trrue");
}
stmt.close();
conn.close();
out.println("false");
}
catch(Exception e){
out.println("NO2 Error");
}
%>