Instead of doing if (myResultSet != null) {
us should do
if (myResultSet.next() != false) {
...
}
as the resultset cursor has to be advanced by next method.
cheers
amit
Amit Kumar Agarwal
Patni Computers Systems
Unit 46, SDF-II, Seepz, Andheri(E)
Mumbai - 400096
Phone: 91-22-8291454 Ext. 5438
-----Original Message-----
From: Brandon Ng [SMTP:nodnarb_33@y...]
Sent: Sunday, May 20, 2001 4:36 PM
To: Pro_JavaServer_Pages
Subject: [pro_jsp] is there anything wrong with this code
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String username = request.getParameter("username");
String password = request.getParameter("password");
Connection myConn = DriverManager.getConnection("jdbc:odbc:cool");
Statement stmt = myConn.createStatement();
ResultSet myResultSet = stmt.executeQuery("Select password from
customer where username =" + username );
if (myResultSet != null) {
if(myResultSet.getString("password") == password )
System.out.println("success");
else
System.out.println("fail");
}
stmt.close();
myConn.close();
%>
This is my trial login processing jsp. What is wrong with the code?
Anyone can help? Also, how do u check whether a username is already being
used when a user register?
-