Do not search on the Java side. It is unnecessarily slow and memorizing memory. You basically do the work for which the database is intended. Just let the database complete the task designed to: select and return exactly the data that you want using SQL permissions.
Start exploring the SQL WHERE . For example, to verify that the username / password matches, follow these steps:
connection = database.getConnection(); preparedStatement = connection.prepareStatement("SELECT * FROM user WHERE username=? AND password=md5(?)"); preparedStatement.setString(1, username); preparedStatement.setString(2, password); resultSet = preparedStatement.executeQuery(); if (resultSet.next()) { // Match found! } else { // No match! }
source share