ResultSet returning nothing
try
{
// Load the JDBC driver
ResultSet rs = null;
String driverName = "com.mysql.jdbc.Driver"; // MySQL MM JDBC driver
Class.forName (driverName);
// Create a connection to the database
serverName = "fedex.plastikracing.net";
mydatabase = "web5_db1";
url = "jdbc:mysql://" + serverName + "/" + mydatabase; // a JDBC url
dbuser = "web5_u1";
dbpass = "password";
connection = DriverManager.getConnection (url, dbuser, dbpass);
Statement stmt = connection.createStatement ();
String sql = "SELECT id FROM users WHERE email = ? AND password = ?";
PreparedStatement pstmt = connection.prepareStatement (sql);
String password = new String (t_pass.getPassword ());
// Set the values
pstmt.setString (1, t_email.getText ());
pstmt.setString (2, passHash (password));
JOptionPane.showMessageDialog (login.this,"E-mail: " + t_email.getText () + "\nPassword: " + passHash (password) , "Connection Error",
JOptionPane.ERROR_MESSAGE);
rs = pstmt.executeQuery ();
rs.next ();
int id = rs.getInt (1);
JOptionPane.showMessageDialog (login.this,id , "UserID",
JOptionPane.ERROR_MESSAGE);
}
catch (SQLException e)
{
// Could not connect to the database
JOptionPane.showMessageDialog (login.this,"Error: " + e.getMessage (), "Connection Error",
JOptionPane.ERROR_MESSAGE);
}
catch (ClassNotFoundException e)
{
// Could not find the database driver
JOptionPane.showMessageDialog (login.this,"Could not find the database driver. \n" + e.getMessage (), "Connection Error",
JOptionPane.ERROR_MESSAGE);
}
I also have a JOptionPane in there for testing purposes that pops up whenever they click "login" that displays the exact values being inserted into my SQL query. My problem is, when I run this I get:
"Illegal operation on empty result set"
If I type in the query in phpMyAdmin, it runs just fine.

