blob: 3144afdf62d365c8780179dc9d4e13e5c4a66f82 [file] [log] [blame]
{
"classLoaderSharing" : "workflow",
"script" : "import java.sql.Driver;\nimport java.sql.DriverManager;\nimport java.sql.Connection;\nimport java.sql.PreparedStatement;\n\nif ((driver == void) || (driver == null) || driver.equals(\"\")) {\n\tthrow new RuntimeException(\"The driver must be specified\");\n}\n\nif ((url == void) || (url == null) || url.equals(\"\")) {\n\tthrow new RuntimeException(\"The url must be specified\");\n}\n\nif ((params == void) || (params == null)) {\n params = new ArrayList();\n}\n\nif ((sql == void) || (sql == null) || sql.equals(\"\")) {\n\tthrow new RuntimeException(\"The sql must be specified\");\n}\n\nClass c = Thread.currentThread().getContextClassLoader().loadClass(driver);\n\nif (c == null) {\n\tthrow new RuntimeException(\"Class \" + driver + \" not found\");\n}\n\nDriver d = c.newInstance();\nif (d == null) {\n\tthrow new RuntimeException(\"Could not create instance of driver\");\n}\n\nProperties p = new Properties();\n\nif ((userid == void) || (userid == null)) {\n\tuserid = \"\";\n}\n\np.setProperty(\"user\", userid);\n\nif ((password == void) || (password == null)) {\n\tpassword = \"\";\n}\n\np.setProperty(\"password\", password);\n\nConnection con = null;\nPreparedStatement ps = null;\n\ntry {\n\tcon = d.connect(url, p);\n\tps = con.prepareStatement(sql);\n\n\tint paramsSize = params.size();\n\tfor (int i = 0; i < paramsSize; i++) {\n\t\tps.setObject(i + 1, params.get(i));\n\t}\n\n\tps.executeUpdate();\n\n\tresultList = \"update successful\";\n}\nfinally {\n\tif (ps != null) {\n\t\tps.close();\n\t}\n\tif (con != null) {\n\t\tcon.close();\n\t}\n}\n\n",
"localworkerName" : "net.sourceforge.taverna.scuflworkers.jdbc.SQLUpdateWorker",
"inputPorts" : [ {
"name" : "driver",
"depth" : 0,
"type" : "String"
}, {
"name" : "password",
"depth" : 0,
"type" : "String"
}, {
"name" : "userid",
"depth" : 0,
"type" : "String"
}, {
"name" : "url",
"depth" : 0,
"type" : "String"
}, {
"name" : "sql",
"depth" : 0,
"type" : "String"
}, {
"name" : "params",
"depth" : 1,
"type" : "String"
} ],
"outputPorts" : [ {
"name" : "resultList",
"depth" : 0,
"granularDepth" : 0
} ],
"isAltered" : false
}