Hey, I am trying to create a voting system I've got a MySQL DB already up (using WAMP) and I'm using Eclipse Galileo with GWT. I have looked everywhere on how to make this connection and now I am sure I connect to the DB at least, however I am unsure regarding if I actually retrieve anything from it and I can't print anything because it throws me an exception. This is the method that should access the DB:
public User authenticateUser(String user1, String pass) { User user = null; try { PreparedStatement ps = conn.prepareStatement( "SELECT user, pass FROM usuarios WHERE user = \"" + user1 + "\" AND " + "pass = \"" + pass + "\"" ); ResultSet result = ps.executeQuery(); while (result.next()) { user = new User(result.getString(2), result.getString(3)); System.out.println(user.getUser().toString()); System.out.println("toy aqui"); } result.close(); ps.close(); } catch (SQLException sqle) { System.err.println("Fail!! = " + sqle.getStackTrace()); } return user; } "conn" is a Connection already made here: public MySQLConnection() { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection(url, user, pass); } catch (Exception e) { System.err.println("Fail en la Conexion = " + e.getStackTrace ()); } } after this, I use this method which should allow me to access stuff from the newly created object: private class AuthenticationHandler<T> implements AsyncCallback<User> { public void onFailure(Throwable ex) { label.setText("Fail"); System.out.println(ex.getStackTrace()); } public void onSuccess(User result) { try { label.setText("Success");// + " Pass:: " + result.getPass ().toString() }catch(Exception e) { System.err.println("Fail! = " + e.getStackTrace()); } } } The thing is, it doesn't matter if I introduce wrong values for the Query to be made with, (user1 and pass) I get success or fail everytime depending on which I started with. That is, if I tried once and failed, then everytime after I will get "Fail" and if I try and get the write data in I will get "Success" everytime. I don't know why this happens and I am unsure I am performing the query the way it should be done. The only thing I'm 100% sure of is that the DB connection is made, and that if I try to print "result.getUser();" in the last method I placed here, I get an exception. What am I missing or doing incorrectly? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-toolkit@googlegroups.com To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en -~----------~----~----~----~------~----~------~--~---