I am having a proplem checking the stu_uid for a specified stu_password.
I am not really sure what error is. When I build the db for the first time and login as a
student
it says that unknown user name but it is all in the table and passed to the method good
is the password char[]
the correct way to pass as a param?
run:
driver tableName from xml: org.apache.derby.jdbc.EmbeddedDriver
in bCreatedTables:
created table: createAdminTable
created table: createPayeeTable
created table: createStudentTable
created table: createInstructorTable
created table: createBookingTable
created table: createInstrAvailableTable
created table: createInstrumentTable
created table: createLocationTable
created table: createPaymentTable
created table: createPayrollTable
created table: createUserTable
created table: createUserGroupMappingTable
created table: createUserGroupTable
driver tableName from xml: org.apache.derby.jdbc.EmbeddedDriver
db and tables created:
inserted data int: insertAdminTable
inserted data int: insertPayeeTable
inserted data int: insertStudentTable
inserted data int: insertInstructorTable
inserted data int: insertPaymentTable
inserted data int: insertUserTable
inserted data int: insertUserGroupTable
inserted data int: insertUserGroupMappingTable
CONECTION IS GOOD FOR A TEST
test string query: SELECT * FROM student
number of columns: 15
, STU_UID, STU_PASSWORD, STU_LNAME, STU_MNAME, STU_FNAME, STU_GENDER, STU_AGE,
STU_START_DATE, STU_END_DATE, STU_ADDRESS, STU_STATE, STU_ZIP, STU_AREA_CODE, STU_PHONE,
PAYEE_UID
, sj, s, null, null, Johnny, null, null, null, null, null, null, null, null, null, null
, ss, s, null, null, Suzie, null, null, null, null, null, null, null, null, null, null
in StudentDAO.JAVA and in connect of the ConnectDerbyDAO
returns isConnected: true
shutdown database
disconnected after building the database java.sql.SQLNonTransientConnectionException:
Database 'schoolofdb' shutdown.
disconnected after building the database
input from splash: user: sj
in LoginInfoBean
LoginInfoBean password: [C@1f8bd0d
LoginInfoBean user: sj
LoginInfo: user: sj
LoginInfo profile: stu_
all models (Student.java extend LoginInfo.javaall beans extend models
in getConnection of DerbyDAOFactory
driver tableName from xml: org.apache.derby.jdbc.EmbeddedDriver
in StudentDAO.JAVA and in connect of the ConnectDerbyDAO
returns isConnected: true
In ConnectStudent.select(newUser,newPassword)
param passed: select(): newUser: sj newPassword: [C@1f8bd0d
studentUserName: SELECT stu_uid FROM student WHERE stu_password=?
UnknownUserNameException: Unknown user name
code:
public StudentBean select(String newUser, char[] newPassword) throws
UnknownUserNameException, IncorrectPasswordException, LoginException, SQLException,
FileNotFoundException, IOException, ProfileException {
DerbyDAOFactory ddf = new DerbyDAOFactory();
conn = ddf.getConnection();
ps=null;
System.out.println("");
System.out.println("In ConnectStudent.select(newUser,newPassword)");
System.out.println("param passed: select(): "
+ "newUser: " + newUser + " newPassword: " + newPassword);
System.out.println("");
System.out.println("studentUserName"+ModelUtils.getXMLResource("studentUserName"));
System.out.println("");
//[b]
ps = conn.prepareStatement(ModelUtils.getXMLResource("studentUserName"));
ps.setString(1, newPassword.toString());
ResultSet rs = ps.executeQuery();
if (rs.next()) {
String user = rs.getString(1);
System.out.println("user from db: " + user);
}
//[/b]
try {
if (!newUser.equals(user)) {
System.out.println("UnknownUserNameException: Unknown user name");
throw new UnknownUserNameException();
}
} catch (UnknownUserNameException ex) {
ps.close();
rs.close();
String x = ex.getMessage();
ViewUtils vu = new ViewUtils();
vu.addExceptionMessage(x);
}
ps = conn.prepareStatement(ModelUtils.getXMLResource("studentPassword"));
System.out.println("studentPassword: " +
ModelUtils.getXMLResource("studentPassword"));
ps.setString(1, newUser);
rs = ps.executeQuery();
if (rs.next()) {
String password = rs.getString(1);
}
try {
if (!password.equals(newPassword)) {
throw new IncorrectPasswordException();
}
ps = (PreparedStatement) conn.prepareStatement(
ModelUtils.getXMLResource("SelectStudent"));
ps.setString(1, newUser);
System.out.println("SelectStudent: "
+ "\n" + ModelUtils.getXMLResource("SelectStudent"));
rs = ps.executeQuery();
studentUser.setUser(rs.getString(1));
studentUser.setPassword(rs.getString(2));
studentUser.setlName(rs.getString(3));
studentUser.setmName(rs.getString(4));
studentUser.setfName(rs.getString(5));
studentUser.setGender(rs.getString(6));
studentUser.setStartDate(rs.getDate(7));
studentUser.setEndDate(rs.getDate(8));
studentUser.setAge(rs.getInt(9));
studentUser.setAddress(rs.getString(10));
studentUser.setState(rs.getString(11));
studentUser.setZip(rs.getInt(12));
studentUser.setAreaCode(rs.getInt(13));
studentUser.setPhone(rs.getInt(14));
studentUser.setPayRate(rs.getDouble(15));
ps.close();
rs.close();
} catch (IncorrectPasswordException ex) {
ps.close();
rs.close();
String x = ex.getMessage();
ViewUtils vu = new ViewUtils();
vu.addExceptionMessage(x);
}