Servlet + MySql -- UPDATE query will not work

I need  a fresh view, i'm not getting anywhere anymore

public class DBupdate extends HttpServlet {
        public void doGet(HttpServletRequest request,
                          HttpServletResponse response)
                       throws ServletException, IOException {
               PrintWriter out = response.getWriter();
               String driver = "com.mysql.jdbc.Driver";
               String url = "jdbc:mysql://localhost:3306/some-db";
               String username = "some-user";
               String password = "some-password";
               String query = "UPDATE users SET users.changed_pass = \"1\" WHERE users.user_name = \"another-user\";";                       showTable(driver, url, username, password, query, out);

        public void showTable(String driver, String url,
                          String username, String password,
                          String query, PrintWriter out) {
    try {
            // Load database driver if it's not already loaded.
            // Establish network connection to database.
            Connection connection = DriverManager.getConnection(url, username, password);
            Statement statement = connection.createStatement();
                query = "SELECT * FROM users;";
            ResultSet resultSet = statement.executeQuery(query);
            // Print results by steping through each row in the result set.
          while( {
                if (resultSet.getString(1).equals("0")) {
                      firstVisit = "true";
                } else {
                      firstVisit = "false";
            //out.print("this is the resultSet value = " + resultSet.getString(1) );
    catch(ClassNotFoundException cnfe) {
          System.err.println("Error loading driver: " + cnfe);
    catch(SQLException sqle) {
            System.err.println("Error connecting: " + sqle);
    } catch(Exception ex) {
            System.err.println("Error with input: " + ex);

  private static void showResults(ResultSet results)
      throws SQLException {
    while( {
      System.out.print(results.getString(1) + " ");

  private static void printUsage() {
    System.out.println("Usage: PreparedStatements host " +
                       "dbName username password " +
                       "vendor [print].");
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


should be


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
are you getting a compile error? or is it just not updating?

i don't see any declaration for the variable firstVisit.
... but unless your db is set to read uncommitted, you may not see the change as the statement does not get closed before the select
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

benk-master-flashAuthor Commented:
OK let me try this...
You shouldn't need terminating semicolons and it would probably be better to use single quotes for character columns in statements
benk-master-flashAuthor Commented:
I should have posted the question an hour ago...
oh well. good work, nothing link a simple answer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.