/*
- * Copyright (C) 2001, 2002 The Mir-coders group
+ * Copyright (C) 2001-2006 The Mir-coders group
*
* This file is part of Mir.
*
*
* In addition, as a special exception, The Mir-coders gives permission to link
* the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
* and distribute linked combinations including the two. You must obey the
* GNU General Public License in all respects for all of the code used other than
* the above mentioned libraries. If you modify this file, you may extend this
*/
package mir.producer;
-import mir.util.ExceptionRoutines;
import mir.util.ParameterExpander;
-import java.sql.*;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
public class ExternalDbProducerNode extends ProducerNodeDecorator {
private String key;
String expandedPassword = ParameterExpander.expandExpression(aProductionContext.getValueSet(), password);
String expandedQuery = ParameterExpander.expandExpression(aProductionContext.getValueSet(), query);
- if (expandedDriver.equals("postgresql")) {
+ if ("postgresql".equals(expandedDriver)) {
Class.forName("org.postgresql.Driver");
}
- if (expandedDriver.equals("mysql")) {
+ if ("mysql".equals(expandedDriver)) {
Class.forName("com.mysql.jdbc.Driver");
- } else {
+ }
+ else {
throw new Exception("Unsupported DB Driver:" + expandedDriver);
}
ResultSet rs = st.executeQuery(expandedQuery);
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
- ArrayList fieldNames = new ArrayList(numberOfColumns);
+ List fieldNames = new ArrayList(numberOfColumns);
for (int i = 0; i < numberOfColumns; i++) {
fieldNames.add(rsmd.getColumnName(i + 1));
}
while (rs.next() && !isAborted(aProductionContext)) {
- HashMap result = new HashMap();
+ Map result = new HashMap();
Iterator fields = fieldNames.iterator();
while (fields.hasNext()) {
String field = (String) fields.next();