在线急等,关于一个很简单的javabean+jsp登陆问题
昨天发贴问题没有解决,今天再发希望能够解决
初学JSP有许多问题不懂,最近就有一个做登录的,在javabean中定义了两个类
public class ConnUtil {
public static Connection getuser() {
Connection conn = null;
try {
String url = "jdbc:odbc:news ";
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
conn = DriverManager.getConnection(url, " ", " ");
} catch (Exception e) {
System.out.print(e.toString());
}
return conn;
}
public static void closeConnection(Connection conn) {
try {
conn.close();
} catch (Exception e) {
System.out.println(e.toString());
}
}
}
还有一个查询表的
public class UserDenglu {
Connection conn = ConnUtil.getuser();
public ResultSet getdentlu(Connection conn, HttpServletRequest request) {
ResultSet rs = null;
try {
String username = request.getParameter( "username ");
String password = request.getParameter( "password ");
Statement smt = conn.createStatement();
String sql = "select username,password from usersdenglu where username= ' "+username+ " ' ";
sql+= "and password= ' "+password+ " ' ";
smt.executeQuery(sql);
&