JBoss Community

Trying to connect to database through jBPM script task.

created by avatarkim in jBPM - View the full discussion

Hi,

 

I'm trying to access MySql database through jBPM workflow's script task but I'm getting the error code below when the workflow run the script task. I already uploaded the MySQL driver jar file as POJO in the Guvnor and I'm still getting this error.
"No suitable driver found for jdbc:mysql://localhost:3306/test"

so I'm assuming the jBPM need some other way for it to handle MySQL driver jar but I don't know where and what should I do this for this to work.

 

Below is my code in my Workflow's Script Task

 

java.sql.Connection con = null;

java.sql.PreparedStatement pst = null;

java.sql.ResultSet rs = null;

java.sql.ResultSetMetaData rsmd = null;

 

 

String url = "jdbc:mysql://localhost:3306/test";

String user = "root";

String password = "password";

 

 

String temp = "DEBUG: ";

 

 

try

{

    con = java.sql.DriverManager.getConnection(url, user, password);

    pst = con.prepareStatement("SELECT * FROM aquitimber_messages");

    rs = pst.executeQuery();

    rsmd = rs.getMetaData();

 

 

    int rowSize = 0;

    rs.last();

    rowSize = rs.getRow();

    rs.first();

 

 

    for (int countRow = 0; countRow < rowSize; countRow++)

    {

              for (int count = 1; count < rsmd.getColumnCount(); count++)

        {

                              System.out.print(rs.getString(count) + ", ");

                              temp = temp + rs.getString(count) + ", ";

        }

        System.out.println();

        rs.next();

    }

} catch (java.sql.SQLException ex)

{

          System.out.println(ex.getMessage());

          temp = temp +ex.getMessage();

} finally

{

          try

          {

                    if (rs != null)

                    {

                              rs.close();

                    }

                    if (pst != null)

                    {

                              pst.close();

                    }

                    if (con != null)

                    {

                              con.close();

                    }

          } catch (java.sql.SQLException ex)

          {

                    System.out.println(ex.getMessage());

                    temp = temp +ex.getMessage();

          }

}

 

 

kcontext.setVariable("approvalVar_history", temp);

 

 

Any help on this would be greatly appreciated. Thank you.

Reply to this message by going to Community

Start a new discussion in jBPM at Community