dims 01/08/03 04:16:10
Modified: src/org/apache/cocoon/transformation SQLTransformer.java
Log:
Patch from "Ignacio J. Ortega" <[EMAIL PROTECTED]>
for "Making SQLTransformer with Interbase 1.6 JDBC Drivers"
Revision Changes Path
1.13 +48 -18
xml-cocoon2/src/org/apache/cocoon/transformation/SQLTransformer.java
Index: SQLTransformer.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/transformation/SQLTransformer.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- SQLTransformer.java 2001/07/07 11:43:35 1.12
+++ SQLTransformer.java 2001/08/03 11:16:10 1.13
@@ -30,6 +30,9 @@
import org.apache.avalon.framework.component.ComponentSelector;
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.excalibur.datasource.DataSourceComponent;
import org.apache.avalon.excalibur.pool.Recyclable;
import org.apache.cocoon.environment.SourceResolver;
@@ -54,10 +57,10 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* (PWR Organisation & Entwicklung)
* @author <a href="mailto:[EMAIL PROTECTED]">Sven Beauprez</a>
- * @version CVS $Revision: 1.12 $ $Date: 2001/07/07 11:43:35 $ $Author: giacomo $
+ * @version CVS $Revision: 1.13 $ $Date: 2001/08/03 11:16:10 $ $Author: dims $
*/
-public class SQLTransformer extends AbstractTransformer implements Composable,
Recyclable, Disposable {
+public class SQLTransformer extends AbstractTransformer implements Composable,
Recyclable, Disposable, Configurable {
/** The SQL namespace **/
public static final String my_uri = "http://apache.org/cocoon/SQL/2.0";
@@ -122,6 +125,9 @@
/** Check if nr of rows need to be written out. **/
protected String showNrOfRows;
+ /** Is the old-driver turned on? (default is off) */
+ private boolean oldDriver = false;
+
protected ComponentSelector dbSelector = null;
protected ComponentManager manager;
@@ -155,7 +161,18 @@
public void dispose() {
if(this.dbSelector != null) this.manager.release((Component)
this.dbSelector);
}
-
+
+ /**
+ * configure
+ */
+ public void configure(Configuration conf)throws ConfigurationException {
+ if (conf != null) {
+ Configuration child = conf.getChild("old-driver");
+ this.oldDriver = child.getValueAsBoolean(false);
+ getLogger().debug("old-driver is " + this.oldDriver + " for " + this);
+ }
+ }
+
/** BEGIN SitemapComponent methods **/
public void setup(SourceResolver resolver, Map objectModel,
@@ -168,7 +185,7 @@
this.current_query_index = -1;
this.default_properties = new Properties();
this.current_state = SQLTransformer.STATE_OUTSIDE;
-
+
this.parameters = parameters;
this.objectModel = objectModel;
@@ -247,7 +264,7 @@
if (index + 1 < queries.size()) {
executeQuery(index + 1);
}
- this.end(query.row_name);
+ this.end(query.row_name);
}
} else {
query.serializeStoredProcedure();
@@ -699,7 +716,7 @@
protected void setStoredProcedure(boolean flag) {
isstoredprocedure = flag;
}
-
+
protected boolean isStoredProcedure() {
return isstoredprocedure;
}
@@ -707,7 +724,7 @@
protected void setName(String name) {
this.name = name;
}
-
+
protected String getName() {
return name;
}
@@ -817,13 +834,21 @@
}
}
if (!isstoredprocedure) {
- pst = conn.prepareStatement(query,
- ResultSet.TYPE_SCROLL_INSENSITIVE,
- ResultSet.CONCUR_READ_ONLY );
+ if (oldDriver) {
+ pst = conn.prepareStatement(query);
+ } else {
+ pst = conn.prepareStatement(query,
+
ResultSet.TYPE_SCROLL_INSENSITIVE,
+ ResultSet.CONCUR_READ_ONLY );
+ }
} else {
- cst = conn.prepareCall(query,
- ResultSet.TYPE_SCROLL_INSENSITIVE,
- ResultSet.CONCUR_READ_ONLY );
+ if (oldDriver) {
+ cst = conn.prepareCall(query);
+ } else {
+ cst = conn.prepareCall(query,
+ ResultSet.TYPE_SCROLL_INSENSITIVE,
+ ResultSet.CONCUR_READ_ONLY );
+ }
registerOutParameters(cst);
pst = cst;
}
@@ -848,9 +873,13 @@
protected int getNrOfRows() throws SQLException {
int nr = 0;
if (rs!=null) {
- rs.last();
- nr = rs.getRow();
- rs.beforeFirst();
+ if (oldDriver){
+ nr=-1;
+ } else {
+ rs.last();
+ nr = rs.getRow();
+ rs.beforeFirst();
+ }
} else {
if (outParameters!=null) {
nr=outParameters.size();
@@ -947,7 +976,7 @@
rs.close();
}
transformer.end((String)outParametersNames.get(counter));
- }
+ }
}catch (SQLException e) {
transformer.getTheLogger().error("Caught a SQLException", e);
throw e;
@@ -955,7 +984,7 @@
close();
}
}
-
+
}
}
@@ -968,4 +997,5 @@
this.name = name;
}
}
+
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]