MySQL custom stored procedures and triggers--stored Procedure demonstration drop PROCEDURE IF EXISTS pro_test; CREATE PROCEDURE pro_test (in num_in int,out num_out int,inout num_inout) begin//do anything you wantend; parameter interpretation: In: Is the input parameter, input Parameters are passed into the stored procedure as parameters, changing its value will not change its original value, equivalent to the value passed out: This is the output parameter, in the stored procedure to give its value, even if the previous value, its value is only null, The equivalent is to create a new value in the stored procedure and pay out parameters and output INOUT: This is an input and output parameter, it can be understood as the sum of the first two, the simplest is to understand how to pass the object in the command line to call: SET @NM_IN =1, @NM_OUT =2, @NM_INOUT = 3;call proc_test (@NM_IN, @NM_OUT, @NM_INOUT); How to call in Java: Find a way to get connection, getsession () in Hibernate. Connection (); Use Java.Sql.CallableStatemet call=connection (). Preparestatement ("Call proc_test"); Call.executequery () The ResultSet object will be returned, and the number of rows affected will be returned by Call.executeupdate (). --Trigger sample trigger According to the trigger type can be divided into: Insert,update,delete Trigger, according to the trigger time can be divided into: before,after, according to the content of the new and old can be divided into: old,new, where the deletion of only the original, new operation only New, Modify action both have eg: without modifying the USER table once, insert the data before and after the modification to the User_back table: CREATE TRIGGER tri_upgrade_user before UPDATE on USER for each Rowbegininsert into User_back (username,userpwd) VALUES Username,old. USERPWD); INSERT into User_back (username,userpwd) VALUES (NEW. Username,new.USERPWD); END; it's done.