0
以下是java中的代碼段,它從數據庫表中提取電子郵件地址和密碼。從該集合中分離出2列的值?
hashedPassword = encrypter.hashPassword(UserPassword);
Context context = new InitialContext();
DataSource ds = (DataSource)context.lookup("java:comp/env/jdbc/photog");
Connection connection = ds.getConnection();
String sqlStatement = "SELECT email,firstname FROM registrationinformation WHERE password='" + hashedPassword + "'";
PreparedStatement statement = connection.prepareStatement(sqlStatement);
ResultSet set = statement.executeQuery();
上述語句成功執行,但我怎麼分開密碼的電子郵件是那裏的set
?
會有什麼'rs.getString( 「電子郵件」)'返回? – 2012-04-23 19:10:24
它返回數據庫中的電子郵件字段。閱讀此鏈接獲取更多信息http://docs.oracle.com/javase/tutorial/jdbc/basics/retrieving.html – kosa 2012-04-23 19:11:39
所以你的意思是執行sql語句'rs.getString(...)'將返回值屬於該行執行的任何列? – 2012-04-23 19:16:09