Example of jdbc
Created: 2012-05-24 07:37:33
Last updated: 2012-05-24 07:39:06
No description has been set
Preview
Run
Run this Workflow in the Taverna Workbench...
Workflow Components
Authors (0)
Titles (0)
Descriptions (0)
Dependencies (1)
Processors (5)
Name |
Type |
Description |
Execute_SQL_Update |
localworker |
Scriptimport java.sql.Driver;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
if ((driver == void) || (driver == null) || driver.equals("")) {
throw new RuntimeException("The driver must be specified");
}
if ((url == void) || (url == null) || url.equals("")) {
throw new RuntimeException("The url must be specified");
}
if ((params == void) || (params == null)) {
params = new ArrayList();
}
if ((sql == void) || (sql == null) || sql.equals("")) {
throw new RuntimeException("The sql must be specified");
}
Class c = Thread.currentThread().getContextClassLoader().loadClass(driver);
if (c == null) {
throw new RuntimeException("Class " + driver + " not found");
}
Driver d = c.newInstance();
if (d == null) {
throw new RuntimeException("Could not create instance of driver");
}
Properties p = new Properties();
if ((userid == void) || (userid == null)) {
userid = "";
}
p.setProperty("user", userid);
if ((password == void) || (password == null)) {
password = "";
}
p.setProperty("password", password);
Connection con = null;
PreparedStatement ps = null;
try {
con = d.connect(url, p);
ps = con.prepareStatement(sql);
int paramsSize = params.size();
for (int i = 0; i < paramsSize; i++) {
ps.setObject(i + 1, params.get(i));
}
ps.executeUpdate();
resultList = "update successful";
}
finally {
if (ps != null) {
ps.close();
}
if (con != null) {
con.close();
}
}
|
driver_value |
stringconstant |
Valuecom.mysql.jdbc.Driver |
password_value |
stringconstant |
ValueShub1dua!!! |
userid_value |
stringconstant |
Valueroot |
url_value |
stringconstant |
Valuejdbc:mysql://localhost/test |
Datalinks (6)
Source |
Sink |
driver_value:value |
Execute_SQL_Update:driver |
password_value:value |
Execute_SQL_Update:password |
userid_value:value |
Execute_SQL_Update:userid |
url_value:value |
Execute_SQL_Update:url |
sql |
Execute_SQL_Update:sql |
Execute_SQL_Update:resultList |
test |
Uploader
License
All versions of this Workflow are
licensed under:
Version 1
(of 1)
Credits (0)
(People/Groups)
None
Attributions (0)
(Workflows/Files)
None
Shared with Groups (1)
Featured In Packs (0)
None
Log in to add to one of your Packs
Attributed By (0)
(Workflows/Files)
None
Favourited By (1)
Statistics
Other workflows that use similar services
(0)
There are no workflows in myExperiment that use similar services to this Workflow.
Comments (0)
No comments yet
Log in to make a comment