0 Replies Latest reply on May 30, 2005 7:52 PM by mjchecko

    Help!  Sending data to MySQL

    mjchecko

      Hello,

      I am using the following simple connection inside a servlet to update data in MySQL:

      try
       {
       //SETUP THE CONNECTION TO MYSQL
       Statement stmt;
       String MySQLUrl = "jdbc:mysql://localhost:3306/somedb";
       Connection con = DriverManager.getConnection(MySQLUrl,"user","password");
       Debug.print("MySQLUrl = " + MySQLUrl + " AND con = " + con);
       stmt = con.createStatement();
      
       //CREATE THE UPDATE QUERY SYNTAX
       String query = "UPDATE db.tablename SET fieldname = " + NewCtc + " WHERE db.tablename.anotherfield = " + strValue + " AND db.tablename.athirdfield = " + strValue2 + " AND db.tablename.afourthfield = " + strValue3;
      
       //EXECUTE THE UPDATE SQL
       con.setAutoCommit(false);
       stmt.executeUpdate(query);
       con.commit();
       con.close();
      
       } catch(Exception e) {
       e.printStackTrace();
       Debug.print("ERROR in updating my field");
       ResponseType="ERRORUpdatingMyField";
       PrintWriter out = response.getWriter();
       out.print("|ResponseType=" + ResponseType);
       }


      For some reason the data is not available to any other servlet operations until I either restart JBoss or re-deploy the EJB application.

      Any ideas? Please help me I am really stuck...

      - Matt