Question

I have a button in gwt and on each click i want that value should increase in the database. How should i do using stored procedure. Its like hitting like button and increasing the counter on the particular post. new for all this want help.

    public String fun()
    {
           Connection con=null;

           CallableStatement pt=null;

         try
         {

               Class.forName("com.mysql.jdbc.Driver");
               con=DriverManager.getConnection("jdbc:mysql://localhost:3306/check", "root", "root");                


                pt=(CallableStatement)con.prepareCall("{call ask (1)}");

                pt.executeUpdate();

                System.out.println("2");
                         }
                con.close();
                pt.close();

        }

        catch(Exception e)
        {
            e.printStackTrace();
        }
     return""; 
}
}

STORED PROCEDURE:

DELIMITER $$

CREATE DEFINER=root@localhost PROCEDURE ask(IN good int) BEGIN update likepost set hitlike=hitlike+1 where idlikepost=1 ; END

TASK COMPLETED YIPEE!!!!

Was it helpful?

Solution

First of all replace Window.alert("hello"); with e.printStackTrace() to watch the logs.

There is no meaning of Window.alert("hello"); at server side code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top