java代码添加mysql存储过程,触发器

 String procedureSQL = "create procedure USER_EXIST(in loginName varchar(50),out amount int)" +  
                    "select count(*) from sys_menu";
         String  trigger = "create  TRIGGER bj_customer before insert on t_user"+
                          " for each row  begin  insert into t_role(id,rolename) values(new.id,new.username);end"; 

        try {
            Connection connection = getConnection();
             PreparedStatement prepareStatement = connection.prepareStatement(trigger);  
             prepareStatement.executeUpdate(); 

        } catch (SQLException e) {
            e.printStackTrace();
        }

存储过程,触发器 的sql和一般sql没有什么两样,同样的执行

原文地址:https://www.cnblogs.com/longsanshi/p/8431580.html