Hello I am learning how to use setString() for "?" and using
passwords in resultsets.
my password ends up with the error
java.sql.SQLException: Invalid cursor state - no current
row.
Can this error be corrected?
thanks.
run:
driver tableName from xml: org.apache.derby.jdbc.EmbeddedDriver
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@1428ea
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@1428ea
studentPassword: SELECT stu_password FROM student WHERE
stu_uid=?
ResultSet rs= :
org.apache.derby.impl.jdbc.EmbedResultSet40@19113f8
May 18, 2010 5:40:38 AM view.SchoolJDesktopPane login
SEVERE: null
java.sql.SQLException: Invalid cursor state - no current row.
public StudentBean select(String newUser, char[] newPassword)
throws UnknownSubscriberException, IncorrectPasswordException,
LoginException, SQLException, FileNotFoundException, IOException
{
DerbyDAOFactory ddf = new DerbyDAOFactory();
conn = ddf.getConnection();
System.out.println("");
System.out.println("In
ConnectStudent.select(newUser,newPassword)");
System.out.println("param passed: select(): "
+ "newUser: " + newUser + " newPassword: " +
newPassword);
System.out.println("");
ps =
conn.prepareStatement(ModelUtils.getXMLResource("studentPassword
"));
System.out.println("studentPassword:
"+ModelUtils.getXMLResource("studentPassword"));
[b]ps.setString(1, newUser);<--------------------[/b]
ResultSet rs = ps.executeQuery();
System.out.println("ResultSet rs= : "+rs.toString());
String password = rs.getString(1);
System.out.println("password from db: "+password);
if (!password.equals(newPassword)) {
ps.close();
rs.close();
System.out.println("getPassword() is not equal to
rs.getString(2)");
throw new IncorrectPasswordException();
} else {
ps.close();
rs.close();
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));
System.out.println("rs.getString(5): " +
studentUser.getfName());
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();
}