I want to use Beanshell plugins and SQL join queries  to return the name of user(s) for mapping participants. 
It doesn't seem to work. How do I go about doing this 

SELECT username FROM dir_user WHERE criteria = 'something';

Connection con = null;
    try { Class.forName("com.mysql.jdbc.Driver").newInstance();
        con = DriverManager.getConnection("jdbc:mysql://localhost:3307/jwdb?characterEncoding=UTF-8", "root", "");
        if(!con.isClosed()){
            //manually handle insert and update by checking the data is exist or not
            String selectQuery = "SELECT `id` FROM dir_user WHERE `id`=?";
            PreparedStatement stmt = con.prepareStatement(selectQuery);
            stmt.setString(1, id);
            ResultSet rs = stmt.executeQuery();

...
Connection con = null;
    try {
	Class.forName("com.mysql.jdbc.Driver").newInstance();
        con = DriverManager.getConnection("jdbc:mysql://localhost:3307/jwdb?characterEncoding=UTF-8", "root", "London2012");

        if(!con.isClosed()){
            //manually handle insert and update by checking the data is exist or not
            String selectQuery = "SELECT `id` FROM dir_user WHERE `id`=?";
            PreparedStatement stmt = con.prepareStatement(selectQuery);
            stmt.setString(1, id);
            ResultSet rs = stmt.executeQuery();
    } catch (Exception ex) {
        System.err.println("#### Exception: " + ex.getMessage());
    } finally {
        try {
            if(con != null)
                con.close();
        } catch(SQLException e) {}
    }
return rs;
...
  • No labels

4 Comments

  1. What error are you getting?

  2. I am using 

    "SELECT `id` FROM dir_user WHERE `id`='admin';"
    

    There is no error return but it is not mapping the process  to the Admin participant. anyone can run the process

    1. Hi there,

      Please see Bean Shell Programming. Look for Participant Type Plugin. You will see an example on how to set the assignees from the Beanshell.

      Cheers

  3. Hi Garrett i have problem same with you, you can use has variable joget like that

    "SELECT yourfield FROM yourtable where id = ' #assignment.processId# ' ;"