[jboss-user] [jBPM] - Trying to connect to database through jBPM script task.
avatarkim
do-not-reply at jboss.com
Fri Jul 19 04:54:24 EDT 2013
avatarkim [https://community.jboss.org/people/avatarkim] created the discussion
"Trying to connect to database through jBPM script task."
To view the discussion, visit: https://community.jboss.org/message/828814#828814
--------------------------------------------------------------
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
[https://community.jboss.org/message/828814#828814]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130719/6db5c50c/attachment-0001.html
More information about the jboss-user
mailing list