You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by ho...@apache.org on 2001/12/11 23:13:52 UTC
cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/sql ParamTag.java QueryTag.java TransactionTag.java UpdateTag.java
horwat 01/12/11 14:13:52
Modified: standard/examples/conf web.xml
Added: standard/conf sql-rt.tld sql.tld
standard/src/org/apache/taglibs/standard/tag/common/sql
ColumnImpl.java ColumnMetaDataImpl.java
DataSourceWrapper.java DriverTag.java
ParamTagSupport.java QueryTagSupport.java
ResultImpl.java ResultMetaDataImpl.java
RowImpl.java TransactionTagSupport.java
UpdateTagSupport.java
standard/src/org/apache/taglibs/standard/tag/el/sql
ParamTag.java QueryTag.java TransactionTag.java
UpdateTag.java
standard/src/org/apache/taglibs/standard/tag/rt/sql
ParamTag.java QueryTag.java TransactionTag.java
UpdateTag.java
Log:
Implementation of the Database actions.
Revision Changes Path
1.1 jakarta-taglibs/standard/conf/sql-rt.tld
Index: sql-rt.tld
===================================================================
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.0 EA3</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>sql-rt</short-name>
<uri>http://java.sun.com/jstl/ea/sql-rt</uri>
<display-name>JSTL sql RT</display-name>
<description>JSTL 1.0 sql library</description>
<validator>
<validator-class>
org.apache.taglibs.standard.tlv.JstlCoreTLV
</validator-class>
<description>
Provides core validation features for JSTL tags.
</description>
</validator>
<tag>
<name>transaction</name>
<tag-class>org.apache.taglibs.standard.tag.rt.sql.TransactionTag</tag-class>
<body-content>JSP</body-content>
<description>
Provides nested database action elements with a shared Connection,
set up to execute all statements as one transaction.
</description>
<attribute>
<name>dataSource</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>query</name>
<tag-class>org.apache.taglibs.standard.tag.rt.sql.QueryTag</tag-class>
<body-content>JSP</body-content>
<description>
Executes the SQL query defined in its body or through the
sql attribute.
</description>
<attribute>
<name>var</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>sql</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>dataSource</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>startRow</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>maxRows</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>update</name>
<tag-class>org.apache.taglibs.standard.tag.rt.sql.UpdateTag</tag-class>
<body-content>JSP</body-content>
<description>
Executes the SQL update defined in its body or through the
sql attribute.
</description>
<attribute>
<name>var</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>sql</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>dataSource</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>parameter</name>
<tag-class>org.apache.taglibs.standard.tag.rt.sql.ParamTag</tag-class>
<body-content>empty</body-content>
<description>
Sets a parameter in an SQL statement to the specified value.
</description>
<attribute>
<name>value</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>driver</name>
<tag-class>org.apache.taglibs.standard.tag.common.sql.DriverTag</tag-class>
<body-content>empty</body-content>
<description>
Creates a simple DataSource suitable only for prototyping.
</description>
<attribute>
<name>var</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>driverClassName</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>jdbcURL</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>userName</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
</taglib>
1.1 jakarta-taglibs/standard/conf/sql.tld
Index: sql.tld
===================================================================
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.0 EA3</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>sql</short-name>
<uri>http://java.sun.com/jstl/ea/sql</uri>
<display-name>JSTL sql</display-name>
<description>JSTL 1.0 sql library</description>
<validator>
<validator-class>
org.apache.taglibs.standard.tlv.JstlCoreTLV
</validator-class>
<init-param>
<param-name>expressionAttributes</param-name>
<param-value>
transaction:dataSource
query:sql
query:dataSource
query:startRow
query:maxRows
update:sql
update:dataSource
param:value
driver:driver
driver:jdbcURL
driver:userName
</param-value>
<description>
Whitespace-separated list of colon-separated token pairs
describing tag:attribute combinations that accept expressions.
The validator uses this information to determine which
attributes need their syntax validated.
</description>
</init-param>
<description>
Provides core validation features for JSTL tags.
</description>
</validator>
<!-- The validator also listens in order to recover a context parameter -->
<listener>
<listener-class>
org.apache.taglibs.standard.tlv.JstlCoreTLVHelper
</listener-class>
</listener>
<tag>
<name>transaction</name>
<tag-class>org.apache.taglibs.standard.tag.el.sql.TransactionTag</tag-class>
<body-content>JSP</body-content>
<description>
Provides nested database action elements with a shared Connection,
set up to execute all statements as one transaction.
</description>
<attribute>
<name>dataSource</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
<tag>
<name>query</name>
<tag-class>org.apache.taglibs.standard.tag.el.sql.QueryTag</tag-class>
<body-content>JSP</body-content>
<description>
Executes the SQL query defined in its body or through the
sql attribute.
</description>
<attribute>
<name>var</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>sql</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>dataSource</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>startRow</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>maxRows</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>update</name>
<tag-class>org.apache.taglibs.standard.tag.el.sql.UpdateTag</tag-class>
<body-content>JSP</body-content>
<description>
Executes the SQL update defined in its body or through the
sql attribute.
</description>
<attribute>
<name>var</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>sql</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>dataSource</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
<tag>
<name>param</name>
<tag-class>org.apache.taglibs.standard.tag.el.sql.paramTag</tag-class>
<body-content>empty</body-content>
<description>
Sets a parameter in an SQL statement to the specified value.
</description>
<attribute>
<name>value</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
<tag>
<name>driver</name>
<tag-class>org.apache.taglibs.standard.tag.common.sql.DriverTag</tag-class>
<body-content>empty</body-content>
<description>
Creates a simple DataSource suitable only for prototyping.
</description>
<attribute>
<name>var</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>driver</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>jdbcURL</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>userName</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
</taglib>
1.3 +10 -0 jakarta-taglibs/standard/examples/conf/web.xml
Index: web.xml
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/examples/conf/web.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- web.xml 2001/11/21 19:42:05 1.2
+++ web.xml 2001/12/11 22:13:51 1.3
@@ -54,6 +54,16 @@
</taglib>
<taglib>
+ <taglib-uri>http://java.sun.com/jstl/ea/sql</taglib-uri>
+ <taglib-location>/WEB-INF/sql.tld</taglib-location>
+ </taglib>
+
+ <taglib>
+ <taglib-uri>http://java.sun.com/jstl/ea/sql-rt</taglib-uri>
+ <taglib-location>/WEB-INF/sql-rt.tld</taglib-location>
+ </taglib>
+
+ <taglib>
<taglib-uri>/jstl-examples-taglib</taglib-uri>
<taglib-location>/WEB-INF/jstl-examples.tld</taglib-location>
</taglib>
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/ColumnImpl.java
Index: ColumnImpl.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.tag.common.sql;
import java.sql.*;
import javax.servlet.jsp.jstl.sql.*;
/**
* <p>This class encapsulates the value and all meta data for a column
* in a database query result. Instances of this class are returned
* as the result of the <Query> action.</p>
*
* @author Hans Bergsten
*/
public class ColumnImpl extends ColumnMetaDataImpl implements Column {
private Object value;
private ColumnMetaData md;
public ColumnImpl(Object value, ColumnMetaData md) {
this.value = value;
this.md = md;
}
/**
* Returns the column value, or null.
*/
public Object getValue() {
return value;
}
/**
* Returns the default <code>String</code> representation of the
* column's value.
*/
public String toString() {
String stringValue = null;
if (value == null) {
stringValue = "";
}
else {
stringValue = value.toString();
}
return stringValue;
}
/**
* Returns the ColumnMetaDataName
*/
public String getName() throws SQLException {
return md.getName();
}
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/ColumnMetaDataImpl.java
Index: ColumnMetaDataImpl.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.tag.common.sql;
import java.sql.*;
import javax.servlet.jsp.jstl.sql.ColumnMetaData;
/**
* <p>This class encapsulates all meta data for a column in a database query
* result. Instances of this class are used by the <code>ColumnImpl</code>
* instances representing specific column values.
*
* <p>All methods may throw an SQLException. In this case, the exception
* instance may be the same instance as thrown by the corresponding
* <code>java.sql.ResultSetMetaData</code> method when the Column instance
* was created.</p>
*
* <p>Note! Currently this class contains methods corresponding to all
* <code>ResultSetMetaData</code> methods. We may want to remove some of them
* that don't make much sense in the context where this class is used.</p>
*
* @author Hans Bergsten
*/
public class ColumnMetaDataImpl implements ColumnMetaData {
private boolean isAutoIncrement;
private SQLException isAutoIncrementException;
private boolean isCaseSensitive;
private SQLException isCaseSensitiveException;
private boolean isSearchable;
private SQLException isSearchableException;
private boolean isCurrency;
private SQLException isCurrencyException;
private int isNullable;
private SQLException isNullableException;
private boolean isSigned;
private SQLException isSignedException;
private int displaySize;
private SQLException displaySizeException;
private String label;
private SQLException labelException;
private String name;
private SQLException nameException;
private String schemaName;
private SQLException schemaNameException;
private int precision;
private SQLException precisionException;
private int scale;
private SQLException scaleException;
private String tableName;
private SQLException tableNameException;
private String catalogName;
private SQLException catalogNameException;
private int type;
private SQLException typeException;
private String typeName;
private SQLException typeNameException;
private boolean isReadOnly;
private SQLException isReadOnlyException;
private boolean isWritable;
private SQLException isWritableException;
private boolean isDefinitelyWritable;
private SQLException isDefinitelyWritableException;
private String className;
private SQLException classNameException;
/**
* Indicates whether the column is automatically numbered,
* thus read-only.
*/
public boolean isAutoIncrement() throws SQLException {
if (isAutoIncrementException != null) {
throw isAutoIncrementException;
}
return isAutoIncrement;
}
public void setAutoIncrement(boolean value) {
isAutoIncrement = value;
}
public void setAutoIncrementException(SQLException e) {
isAutoIncrementException = e;
}
/**
* Indicates whether a column's case matters.
*/
public boolean isCaseSensitive() throws SQLException {
if (isCaseSensitiveException != null) {
throw isCaseSensitiveException;
}
return isCaseSensitive;
}
void setCaseSensitive(boolean value) {
isCaseSensitive = value;
}
void setCaseSensitiveException(SQLException e) {
isCaseSensitiveException = e;
}
/**
* Indicates whether the column can be used in a where clause.
*/
public boolean isSearchable() throws SQLException {
if (isSearchableException != null) {
throw isSearchableException;
}
return isSearchable;
}
void setSearchable(boolean value) {
isSearchable = value;
}
void setSearchableException(SQLException e) {
isSearchableException = e;
}
/**
* Indicates whether the column is a cash value.
*/
public boolean isCurrency() throws SQLException {
if (isCurrencyException != null) {
throw isCurrencyException;
}
return isCurrency;
}
void setCurrency(boolean value) {
isCurrency = value;
}
void setCurrencyException(SQLException e) {
isCurrencyException = e;
}
/**
* Indicates the nullability of values in the column.
*/
public int isNullable() throws SQLException {
if (isNullableException != null) {
throw isNullableException;
}
return isNullable;
}
void setNullable(int value) {
isNullable = value;
}
void setNullableException(SQLException e) {
isNullableException = e;
}
/**
* Indicates whether values in the column are signed numbers.
*/
public boolean isSigned() throws SQLException {
if (isSignedException != null) {
throw isSignedException;
}
return isSigned;
}
void setSigned(boolean value) {
isSigned = value;
}
void setSignedException(SQLException e) {
isSignedException = e;
}
/**
* Indicates the column's normal maximum width in characters.
*/
public int getDisplaySize() throws SQLException {
if (displaySizeException != null) {
throw displaySizeException;
}
return displaySize;
}
void setDisplaySize(int value) {
displaySize = value;
}
void setDisplaySizeException(SQLException e) {
displaySizeException = e;
}
/**
* Gets the column's suggested title for use in printouts and displays.
*/
public String getLabel() throws SQLException {
if (labelException != null) {
throw labelException;
}
return label;
}
void setLabel(String value) {
label = value;
}
void setLabelException(SQLException e) {
labelException = e;
}
/**
* Get the designated column's name.
*/
public String getName() throws SQLException {
if (nameException != null) {
throw nameException;
}
return name;
}
void setName(String value) {
name = value;
}
void setNameException(SQLException e) {
nameException = e;
}
/**
* Get the column's table's schema.
*/
public String getSchemaName() throws SQLException {
if (schemaNameException != null) {
throw schemaNameException;
}
return schemaName;
}
void setSchemaName(String value) {
schemaName = value;
}
void setSchemaNameException(SQLException e) {
schemaNameException = e;
}
/**
* Get the column's number of decimal digits.
*/
public int getPrecision() throws SQLException {
if (precisionException != null) {
throw precisionException;
}
return precision;
}
void setPrecision(int value) {
precision = value;
}
void setPrecisionException(SQLException e) {
precisionException = e;
}
/**
* Gets the column's number of digits to right of the decimal point.
*/
public int getScale() throws SQLException {
if (scaleException != null) {
throw scaleException;
}
return scale;
}
void setScale(int value) {
scale = value;
}
void setScaleException(SQLException e) {
scaleException = e;
}
/**
* Gets the designated column's table name.
*/
public String getTableName() throws SQLException {
if (tableNameException != null) {
throw tableNameException;
}
return tableName;
}
void setTableName(String value) {
tableName = value;
}
void setTableNameException(SQLException e) {
tableNameException = e;
}
/**
* Gets the column's table's catalog name.
*/
public String getCatalogName() throws SQLException {
if (catalogNameException != null) {
throw catalogNameException;
}
return catalogName;
}
void setCatalogName(String value) {
catalogName = value;
}
void setCatalogNameException(SQLException e) {
catalogNameException = e;
}
/**
* Retrieves the column's SQL type.
*
*<p>Fix: maybe this method should return a String instead, with
* the name of the type based on the java.sql.Types statics names.
*/
public int getType() throws SQLException {
if (typeException != null) {
throw typeException;
}
return type;
}
void setType(int value) {
type = value;
}
void setTypeException(SQLException e) {
typeException = e;
}
/**
* Retrieves the column's database-specific type name.
*/
public String getTypeName() throws SQLException {
if (typeNameException != null) {
throw typeNameException;
}
return typeName;
}
void setTypeName(String value) {
typeName = value;
}
void setTypeNameException(SQLException e) {
typeNameException = e;
}
/**
* Indicates whether the column is definitely not writable.
*/
public boolean isReadOnly() throws SQLException {
if (isReadOnlyException != null) {
throw isReadOnlyException;
}
return isReadOnly;
}
void setReadOnly(boolean value) {
isReadOnly = value;
}
void setReadOnlyException(SQLException e) {
isReadOnlyException = e;
}
/**
* Indicates whether it is possible for a write on the column to succeed.
*/
public boolean isWritable() throws SQLException {
if (isWritableException != null) {
throw isWritableException;
}
return isWritable;
}
void setWritable(boolean value) {
isWritable = value;
}
void setWritableException(SQLException e) {
isWritableException = e;
}
/**
* Indicates whether a write on the column will definitely succeed.
*/
public boolean isDefinitelyWritable() throws SQLException {
if (isDefinitelyWritableException != null) {
throw isDefinitelyWritableException;
}
return isDefinitelyWritable;
}
void setDefinitelyWritable(boolean value) {
isDefinitelyWritable = value;
}
void setDefinitelyWritableException(SQLException e) {
isDefinitelyWritableException = e;
}
/**
* Returns the fully-qualified name of the Java class whose instances
* are manufactured if the method <code>ResultSet.getObject</code> is
* called to retrieve a value from the column.
* <code>ResultSet.getObject</code> may return a subclass of the class
* returned by this method.
*/
public String getClassName() throws SQLException {
if (classNameException != null) {
throw classNameException;
}
return className;
}
void setClassName(String value) {
className = value;
}
void setClassNameException(SQLException e) {
classNameException = e;
}
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/DataSourceWrapper.java
Index: DataSourceWrapper.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.tag.common.sql;
import java.io.*;
import java.sql.*;
import java.util.*;
import javax.sql.*;
/**
* <p>A simple <code>DataSource</code> wrapper for the standard
* <code>DriverManager</code> class.
*
* @author Hans Bergsten
*/
public class DataSourceWrapper implements DataSource {
private static Map loadedDrivers = new HashMap();
private String driverClassName;
private String jdbcURL;
private String userName;
private String password;
public void setDriverClassName(String driverClassName)
throws ClassNotFoundException, InstantiationException,
IllegalAccessException {
this.driverClassName = driverClassName;
if (!isDriverLoaded(driverClassName)) {
Class.forName(driverClassName).newInstance();
}
}
public void setJdbcURL(String jdbcURL) {
this.jdbcURL = jdbcURL;
}
public void setUserName(String userName) {
this.userName = userName;
}
public void setPassword(String password) {
this.password = password;
}
/**
* Returns a Connection using the DriverManager and all
* set properties.
*/
public Connection getConnection() throws SQLException {
Connection conn = null;
if (userName != null) {
conn = DriverManager.getConnection(jdbcURL, userName, password);
}
else {
conn = DriverManager.getConnection(jdbcURL);
}
return conn;
}
/**
* Always throws a SQLException. Username and password are set
* in the constructor and can not be changed.
*/
public Connection getConnection(String username, String password)
throws SQLException {
throw new SQLException("Not supported");
}
/**
* Always throws a SQLException. Not supported.
*/
public int getLoginTimeout() throws SQLException {
throw new SQLException("Not supported");
}
/**
* Always throws a SQLException. Not supported.
*/
public PrintWriter getLogWriter() throws SQLException {
throw new SQLException("Not supported");
}
/**
* Always throws a SQLException. Not supported.
*/
public void setLoginTimeout(int seconds) throws SQLException {
throw new SQLException("Not supported");
}
/**
* Always throws a SQLException. Not supported.
*/
public synchronized void setLogWriter(PrintWriter out) throws SQLException {
throw new SQLException("Not supported");
}
/**
* Returns true if the specified driver class has already been
* loaded.
*/
private boolean isDriverLoaded(String driverClassName) {
if (loadedDrivers.get(driverClassName) != null) {
return true;
}
else {
return false;
}
}
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/DriverTag.java
Index: DriverTag.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.tag.common.sql;
import java.util.*;
import javax.servlet.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.jstl.sql.*;
import javax.servlet.jsp.tagext.*;
/**
* <p>Tag handler for <Driver> in JSTL, used to create
* a simple DataSource for prototyping.</p>
*
* @author Hans Bergsten
*/
public class DriverTag extends TagSupport {
private static final String DRIVER_CLASS_NAME =
"javax.servlet.jsp.jstl.sql.driver";
private static final String JDBC_URL =
"javax.servlet.jsp.jstl.sql.jdbcURL";
private static final String USER_NAME =
"javax.servlet.jsp.jstl.sql.userName";
private static final String PASSWORD =
"javax.servlet.jsp.jstl.sql.password";
private String driverClassName;
private String jdbcURL;
private int scope = PageContext.PAGE_SCOPE;
private String userName;
private String var;
//*********************************************************************
// Accessor methods
public void setDriver(String driverClassName) {
this.driverClassName = driverClassName;
}
public void setJdbcURL(String jdbcURL) {
this.jdbcURL = jdbcURL;
}
/**
* Setter method for the scope of the variable to hold the
* result.
*
*/
public void setScope(String scopeName) {
if ("page".equals(scopeName)) {
scope = PageContext.PAGE_SCOPE;
}
else if ("request".equals(scopeName)) {
scope = PageContext.REQUEST_SCOPE;
}
else if ("session".equals(scopeName)) {
scope = PageContext.SESSION_SCOPE;
}
else if ("application".equals(scopeName)) {
scope = PageContext.APPLICATION_SCOPE;
}
}
public void setUserName(String userName) {
this.userName = userName;
}
public void setVar(String var) {
this.var = var;
}
//*********************************************************************
// Tag logic
public int doStartTag() throws JspException {
DataSourceWrapper ds = new DataSourceWrapper();
try {
ds.setDriverClassName(getDriverClassName());
}
catch (Exception e) {
throw new JspTagException("Invalid driver class name: " +
e.getMessage());
}
ds.setJdbcURL(getJdbcURL());
ds.setUserName(getUserName());
ds.setPassword(getPassword());
pageContext.setAttribute(var, ds, scope);
return SKIP_BODY;
}
//*********************************************************************
// Private utility methods
private String getDriverClassName() {
if (driverClassName != null) {
return driverClassName;
}
ServletContext application = pageContext.getServletContext();
return application.getInitParameter(DRIVER_CLASS_NAME);
}
private String getJdbcURL() {
if (jdbcURL != null) {
return jdbcURL;
}
ServletContext application = pageContext.getServletContext();
return application.getInitParameter(JDBC_URL);
}
private String getUserName() {
if (userName != null) {
return userName;
}
ServletContext application = pageContext.getServletContext();
return application.getInitParameter(USER_NAME);
}
private String getPassword() {
ServletContext application = pageContext.getServletContext();
return application.getInitParameter(PASSWORD);
}
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/ParamTagSupport.java
Index: ParamTagSupport.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.tag.common.sql;
import java.util.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.jstl.sql.*;
import javax.servlet.jsp.tagext.*;
/**
* <p>Tag handler for <Param> in JSTL, used to set
* parameter values for a SQL statement.</p>
*
* @author Hans Bergsten
*/
public abstract class ParamTagSupport extends BodyTagSupport {
protected Object value;
//*********************************************************************
// Tag logic
public int doEndTag() throws JspException {
SQLExecutionTag parent = (SQLExecutionTag)
findAncestorWithClass(this, SQLExecutionTag.class);
if (parent == null) {
throw new JspTagException("'sqlValue' used in the wrong context");
}
Object paramValue = null;
if (value != null) {
paramValue = value;
}
else if (bodyContent != null) {
paramValue = bodyContent.getString().trim();
if (((String) paramValue).trim().length() == 0) {
paramValue = null;
}
}
if (paramValue == null) {
throw new JspTagException("No value specified");
}
parent.addSQLParameter(paramValue);
return EVAL_PAGE;
}
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/QueryTagSupport.java
Index: QueryTagSupport.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.tag.common.sql;
import java.sql.*;
import java.util.*;
import javax.sql.*;
import javax.servlet.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.jstl.sql.*;
import javax.servlet.jsp.tagext.*;
/**
* <p>Tag handler for <Query> in JSTL.
*
* @author Hans Bergsten
*/
public abstract class QueryTagSupport extends BodyTagSupport
implements TryCatchFinally, SQLExecutionTag {
private static final String MAX_ROWS =
"javax.servlet.jsp.jstl.sql.maxRows";
private String var;
private int scope;
private int maxRows;
private int startRow;
/*
* The following properties take expression values, so the
* setter methods are implemented by the expression type
* specific subclasses.
*/
protected DataSource dataSource;
protected String sql;
/*
* Instance variables that are not for attributes
*/
private Connection conn;
private List parameters;
private boolean isPartOfTransaction;
//*********************************************************************
// Constructor
public QueryTagSupport() {
super();
init();
}
private void init() {
scope = PageContext.PAGE_SCOPE;
startRow = 1;
try {
maxRows = Integer.parseInt(
pageContext.getServletContext().getInitParameter(MAX_ROWS));
} catch (Exception ex) {
maxRows = 0;
}
}
//*********************************************************************
// Accessor methods
/**
* Setter method for the name of the variable to hold the
* result.
*
*/
public void setVar(String var) {
this.var = var;
}
/**
* Setter method for the scope of the variable to hold the
* result.
*
*/
public void setScope(String scopeName) {
if ("page".equals(scopeName)) {
scope = PageContext.PAGE_SCOPE;
}
else if ("request".equals(scopeName)) {
scope = PageContext.REQUEST_SCOPE;
}
else if ("session".equals(scopeName)) {
scope = PageContext.SESSION_SCOPE;
}
else if ("application".equals(scopeName)) {
scope = PageContext.APPLICATION_SCOPE;
}
}
/**
* Setter method for the startRow
*
*/
public void setStartRow(int start) {
startRow = start;
}
/**
* Setter method for the maxRows
*
*/
public void setMaxRows(int max) {
maxRows = max;
}
//*********************************************************************
// Public utility methods
/**
* Called by nested parameter elements to add PreparedStatement
* parameter values.
*/
public void addSQLParameter(Object o) {
if (parameters == null) {
parameters = new ArrayList();
}
parameters.add(o);
}
//*********************************************************************
// Tag logic
/**
* Prepares for execution by setting the initial state, such as
* getting the <code>Connection</code>
*/
public int doStartTag() throws JspException {
try {
conn = getConnection();
}
catch (SQLException e) {
throw new JspTagException("Error getting connection: " +
e.getMessage());
}
return EVAL_BODY_BUFFERED;
}
/**
* <p>Execute the SQL statement, set either through the <code>sql</code>
* attribute or as the body, and save the result as a variable
* named by the <code>var</code> attribute in the scope specified
* by the <code>scope</code> attribute, as an object that implements
* the Result interface.
*
* <p>The connection used to execute the statement comes either
* from the <code>DataSource</code> specified by the
* <code>dataSource</code> attribute, provided by a parent action
* element, or is retrieved from a JSP scope attribute
* named <code>javax.servlet.jsptl.DataSource</code>.
*/
public int doEndTag() throws JspException {
/*
* Use the SQL statement specified by the sql attribute, if any,
* otherwise use the body as the statement.
*/
String sqlStatement = null;
if (sql != null) {
sqlStatement = sql;
}
else if (bodyContent != null) {
sqlStatement = bodyContent.getString();
}
if (sqlStatement == null || sqlStatement.trim().length() == 0) {
throw new JspTagException("No SQL statement specified");
}
Result result = null;
try {
PreparedStatement ps = conn.prepareStatement(sqlStatement);
if (maxRows > 0 ) {
ps.setMaxRows(maxRows);
}
setParameters(ps, parameters);
ResultSet rs = ps.executeQuery();
result = new ResultImpl(rs, startRow, (maxRows > 0));
}
catch (SQLException e) {
throw new JspTagException("Error processing SQL: " +
e.getMessage());
}
pageContext.setAttribute(var, result, scope);
return SKIP_BODY;
}
/**
* Just rethrows the Throwable.
*/
public void doCatch(Throwable t) throws Throwable {
throw t;
}
/**
* Close the <code>Connection</code>, unless this action is used
* as part of a transaction.
*/
public void doFinally() {
if (conn != null && !isPartOfTransaction) {
try {
conn.close();
}
catch (SQLException e) {} // Not much we can do
}
/*
* Reset the per-invokation state.
*/
parameters = null;
isPartOfTransaction = false;
conn = null;
}
//*********************************************************************
// Private utility methods
private Connection getConnection() throws SQLException {
// Fix: Add all other mechanisms
Connection conn = null;
TransactionTag parent = (TransactionTag)
findAncestorWithClass(this, TransactionTag.class);
if (parent != null) {
conn = parent.getSharedConnection();
}
else {
conn = dataSource.getConnection();
}
return conn;
}
private void setParameters(PreparedStatement ps, List parameters)
throws SQLException {
if (parameters != null) {
for (int i = 0; i < parameters.size(); i++) {
// The first parameter has index 1
ps.setObject(i + 1, parameters.get(i));
}
}
}
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/ResultImpl.java
Index: ResultImpl.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.tag.common.sql;
import java.sql.*;
import java.util.*;
import javax.servlet.jsp.jstl.sql.*;
/**
* <p>This class creates a cached version of a <code>ResultSet</code>.
* It's represented as a <code>Result</code> implementation, capable of
* returing an array of <code>Row</code> objects containing a <code>Column</code>
* instance for each column in the row.
*
* @author Hans Bergsten
*/
public class ResultImpl implements Result {
private List rows;
private ResultMetaData resultMD;
private boolean isLimited;
/**
* This constructor reads the ResultSet and saves a cached
* copy.
*
* @param rs an open <code>ResultSet</code>, positioned before the
* first row
* @param startRow, beginning row to be cached
* @param isLimited, whether the query had a MaxRows limit
* @exception if a database error occurs
*/
public ResultImpl(ResultSet rs, int startRow, boolean isLimited) throws SQLException {
this.isLimited = isLimited;
ResultSetMetaData rsmd = rs.getMetaData();
int noOfColumns = rsmd.getColumnCount();
resultMD = new ResultMetaDataImpl(rsmd);
rows = new ArrayList();
int beginRow = 0;
while (rs.next()) {
beginRow++;
if (beginRow >= startRow) {
Column[] columns = new ColumnImpl[noOfColumns + 1];
// JDBC uses 1 as the lowest index!
for (int i = 1; i <= noOfColumns; i++) {
Object value = rs.getObject(i);
if (rs.wasNull()) {
value = null;
}
columns[i] = new ColumnImpl(value, resultMD.get(i));
}
Row currentRow = new RowImpl(columns);
rows.add(currentRow);
}
}
}
/**
* Returns an array of Row objects.
*
* @return an array of Rows, or null if there are no rows
*/
public Row[] getRows() {
if (rows == null) {
return null;
}
Row[] rowArray = new Row[rows.size() + 1];
int index = 0;
Iterator i = rows.iterator();
while (i.hasNext()) {
index++;
rowArray[index] = (Row) i.next();
}
return rowArray;
}
/**
* Returns the number of rows in the cached ResultSet
*
* @return the number of cached rows, or -1 if the Result could
* not be initialized due to SQLExceptions
*/
public int getSize() {
if (rows == null) {
return -1;
}
return rows.size();
}
/**
* Returns the ResultMetaData object of the cached ResultSet
*
* @return the ResultMetaData object
*/
public ResultMetaData getMetaData() {
return resultMD;
}
/**
* Returns true of the query was limited by a maximum row setting
*
* @return true if the query was limited by a MaxRows attribute
*/
public boolean isLimitedByMaxRows() {
return isLimited;
}
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/ResultMetaDataImpl.java
Index: ResultMetaDataImpl.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.tag.common.sql;
import java.sql.*;
import java.util.*;
import javax.servlet.jsp.jstl.sql.*;
/**
* <p>This class encapsulates all the meta data for a result set. Instances
* of this class are used by the <code>ResultImpl</code> instances.</p>
*
* @author Hans Bergsten
*/
public class ResultMetaDataImpl implements ResultMetaData {
private ColumnMetaData[] columnMD;
/**
* This constructor creates a ColumnMetaData object from the ResultSetMetaData
*
* @param rsmd ResultSetMetaData object
* @exception if a database error occurs
*/
public ResultMetaDataImpl (ResultSetMetaData rsmd) throws SQLException {
int noOfColumns = rsmd.getColumnCount();
// JDBC uses 1 as the lowest index!
columnMD = new ColumnMetaData[noOfColumns + 1];
getMetaDataCache(rsmd);
}
/**
* Returns the ColumnMetaData for the named column
*
* @param name the name of the column
* @exception if a database error occurs
*
* @return the ColumnMetaData object of the named column
*/
public ColumnMetaData get(String name) {
for (int i = 1; i <= columnMD.length; i++) {
try {
if (name.equals(columnMD[i].getName())) {
return columnMD[i];
}
} catch (SQLException ex) {
// can't get the column
}
}
return null;
}
/**
* Returns the ColumnMetaData for the given column index
*
* @param index the index of the column
*
* @return the ColumnMetaData object of the indexed column
*/
public ColumnMetaData get(int index) {
if ((index > 0) && (index <= columnMD.length)) {
return (ColumnMetaData) columnMD[index];
}
return null;
}
/**
* Returns an array of ColumnMetaData objects
*
* @return an array of ColumnMetaData objects
*/
public ColumnMetaData[] getColumns() {
return columnMD;
}
/**
* Returns an array of ColumnMetaData instances for all columns.
* All Column instances for a specific column in all rows share
* the same ColumnMetaData instance.
*/
private void getMetaDataCache(ResultSetMetaData rsmd)
throws SQLException {
int noOfColumns = rsmd.getColumnCount();
for (int i = 1; i <= noOfColumns; i++) {
ColumnMetaData md = new ColumnMetaDataImpl();
try {
((ColumnMetaDataImpl)md).setAutoIncrement(rsmd.isAutoIncrement(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setAutoIncrementException(e);
}
try {
((ColumnMetaDataImpl)md).setCaseSensitive(rsmd.isCaseSensitive(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setCaseSensitiveException(e);
}
try {
((ColumnMetaDataImpl)md).setSearchable(rsmd.isSearchable(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setSearchableException(e);
}
try {
((ColumnMetaDataImpl)md).setCurrency(rsmd.isCurrency(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setCurrencyException(e);
}
try {
((ColumnMetaDataImpl)md).setNullable(rsmd.isNullable(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setNullableException(e);
}
try {
((ColumnMetaDataImpl)md).setSigned(rsmd.isSigned(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setSignedException(e);
}
try {
((ColumnMetaDataImpl)md).setDisplaySize(rsmd.getColumnDisplaySize(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setDisplaySizeException(e);
}
try {
((ColumnMetaDataImpl)md).setLabel(rsmd.getColumnLabel(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setLabelException(e);
}
try {
((ColumnMetaDataImpl)md).setName(rsmd.getColumnName(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setNameException(e);
}
try {
((ColumnMetaDataImpl)md).setSchemaName(rsmd.getSchemaName(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setSchemaNameException(e);
}
try {
((ColumnMetaDataImpl)md).setPrecision(rsmd.getPrecision(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setPrecisionException(e);
}
try {
((ColumnMetaDataImpl)md).setScale(rsmd.getScale(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setScaleException(e);
}
try {
((ColumnMetaDataImpl)md).setTableName(rsmd.getTableName(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setTableNameException(e);
}
try {
((ColumnMetaDataImpl)md).setCatalogName(rsmd.getCatalogName(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setCatalogNameException(e);
}
try {
((ColumnMetaDataImpl)md).setType(rsmd.getColumnType(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setTypeException(e);
}
try {
((ColumnMetaDataImpl)md).setTypeName(rsmd.getColumnTypeName(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setTypeNameException(e);
}
try {
((ColumnMetaDataImpl)md).setReadOnly(rsmd.isReadOnly(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setReadOnlyException(e);
}
try {
((ColumnMetaDataImpl)md).setWritable(rsmd.isWritable(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setWritableException(e);
}
try {
((ColumnMetaDataImpl)md).setDefinitelyWritable(rsmd.isDefinitelyWritable(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setDefinitelyWritableException(e);
}
try {
((ColumnMetaDataImpl)md).setClassName(rsmd.getColumnClassName(i));
}
catch (SQLException e) {
((ColumnMetaDataImpl)md).setClassNameException(e);
}
columnMD[i] = md;
}
return;
}
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/RowImpl.java
Index: RowImpl.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.tag.common.sql;
import java.sql.*;
import java.util.*;
import javax.servlet.jsp.jstl.sql.*;
/**
* <p>This class encapsulates the columns for a given row.
* Used by the <code>ResultImpl</code> to cache the result set </p>
*
* @author Hans Bergsten
*/
public class RowImpl implements Row {
private Column[] columns;
/**
* This constructor saves the columns associated with a row
*
* @param columns an array of columns
*/
public RowImpl(Column[] columns) {
this.columns = columns;
}
/**
* Returns the Column object for the named column
*
* @param name the name of the column
* @exception if a database error occurs
*
* @return the Column object of the named column
*/
public Column get(String name) {
for (int i=1; i < columns.length; i++) {
try {
if (name.equalsIgnoreCase(columns[i].getName())) {
return columns[i];
}
} catch (SQLException ex) {
// can't get the column
}
}
return null;
}
/**
* Returns the Column for the given column index
*
* @param index the index of the column
*
* @return the Column object of the indexed column
*/
public Column get(int index) {
if ((index > 0) && (index <= columns.length)) {
return columns[index];
}
return null;
}
/**
* Returns an array Column objects
*
* @return an array of Column objects
*/
public Column[] getColumns() {
return columns;
}
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/TransactionTagSupport.java
Index: TransactionTagSupport.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.tag.common.sql;
import java.sql.*;
import java.util.*;
import javax.sql.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.jstl.sql.*;
import javax.servlet.jsp.tagext.*;
/**
* <p>Tag handler for <Transaction> in JSTL.
*
* @author Hans Bergsten
*/
public abstract class TransactionTagSupport extends TagSupport
implements TryCatchFinally {
private static final int DEFAULT_ISOLATION = -1;
private int transactionIsolation = DEFAULT_ISOLATION;
/*
* The following properties take expression values, so the
* setter methods are implemented by the expression type
* specific subclasses.
*/
protected DataSource dataSource;
/*
* Instance variables that are not for attributes
*/
private Connection conn;
private int origIsolation;
//*********************************************************************
// Public utility methods
/**
* Setter method for the transaction isolation level.
*/
public void setTransactionIsolation(String transactionIsolation)
throws JspTagException {
if ("TRANSACTION_READ_COMMITTED".equals(transactionIsolation)) {
this.transactionIsolation = Connection.TRANSACTION_READ_COMMITTED;
}
if ("TRANSACTION_READ_UNCOMMITTED".equals(transactionIsolation)) {
this.transactionIsolation = Connection.TRANSACTION_READ_UNCOMMITTED;
}
if ("TRANSACTION_REPEATABLE_READ".equals(transactionIsolation)) {
this.transactionIsolation = Connection.TRANSACTION_REPEATABLE_READ;
}
if ("TRANSACTION_SERIALIZABLE".equals(transactionIsolation)) {
this.transactionIsolation = Connection.TRANSACTION_SERIALIZABLE;
}
else {
throw new JspTagException("Invalid transaction isolation");
}
}
/**
* Called by nested parameter elements to get a reference to
* the Connection.
*/
public Connection getSharedConnection() {
return conn;
}
//*********************************************************************
// Tag logic
/**
* Prepares for execution by setting the initial state, such as
* getting the <code>Connection</code> and preparing it for
* the transaction.
*/
public int doStartTag() throws JspException {
try {
conn = getConnection();
int origIsolation = conn.getTransactionIsolation();
if (origIsolation == Connection.TRANSACTION_NONE) {
throw new JspTagException("The DataSource does not support transactions");
}
if (transactionIsolation != DEFAULT_ISOLATION &&
origIsolation != transactionIsolation) {
conn.setTransactionIsolation(transactionIsolation);
}
conn.setAutoCommit(false);
}
catch (SQLException e) {
throw new JspTagException("Error getting connection: " +
e.getMessage());
}
return EVAL_BODY_INCLUDE;
}
/**
* Commits the transaction.
*/
public int doEndTag() throws JspException {
try {
conn.commit();
}
catch (SQLException e) {
throw new JspTagException("Error committing transaction: " +
e.getMessage());
}
return EVAL_PAGE;
}
/**
* Rollbacks the transaction and rethrows the Throwable.
*/
public void doCatch(Throwable t) throws Throwable {
if (conn != null) {
try {
conn.rollback();
}
catch (SQLException e) {} // Ignore to not hide orignal exception
}
throw t;
}
/**
* Restores the <code>Connection</code> to its initial state and closes
* it.
*/
public void doFinally() {
if (conn != null) {
try {
if (transactionIsolation != DEFAULT_ISOLATION &&
origIsolation != transactionIsolation) {
conn.setTransactionIsolation(origIsolation);
}
conn.setAutoCommit(true);
conn.close();
}
catch (SQLException e) {} // Not much we can do
}
conn = null;
}
//*********************************************************************
// Private utility methods
private Connection getConnection() throws SQLException {
// Fix: Add all other mechanisms
return dataSource.getConnection();
}
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/UpdateTagSupport.java
Index: UpdateTagSupport.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.tag.common.sql;
import java.sql.*;
import java.util.*;
import javax.sql.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.jstl.sql.*;
import javax.servlet.jsp.tagext.*;
/**
* <p>Tag handler for <Update> in JSTL.
*
* @author Hans Bergsten
*/
public abstract class UpdateTagSupport extends BodyTagSupport
implements TryCatchFinally, SQLExecutionTag {
private String var;
private int scope = PageContext.PAGE_SCOPE;
/*
* The following properties take expression values, so the
* setter methods are implemented by the expression type
* specific subclasses.
*/
protected DataSource dataSource;
protected String sql;
/*
* Instance variables that are not for attributes
*/
private Connection conn;
private List parameters;
private boolean isPartOfTransaction;
//*********************************************************************
// Accessor methods
/**
* Setter method for the name of the variable to hold the
* result.
*
*/
public void setVar(String var) {
this.var = var;
}
/**
* Setter method for the scope of the variable to hold the
* result.
*
*/
public void setScope(String scopeName) {
if ("page".equals(scopeName)) {
scope = PageContext.PAGE_SCOPE;
}
else if ("request".equals(scopeName)) {
scope = PageContext.REQUEST_SCOPE;
}
else if ("session".equals(scopeName)) {
scope = PageContext.SESSION_SCOPE;
}
else if ("application".equals(scopeName)) {
scope = PageContext.APPLICATION_SCOPE;
}
}
//*********************************************************************
// Public utility methods
/**
* Called by nested parameter elements to add PreparedStatement
* parameter values.
*/
public void addSQLParameter(Object o) {
if (parameters == null) {
parameters = new ArrayList();
}
parameters.add(o);
}
//*********************************************************************
// Tag logic
/**
* Prepares for execution by setting the initial state, such as
* getting the <code>Connection</code>
*/
public int doStartTag() throws JspException {
try {
conn = getConnection();
}
catch (SQLException e) {
throw new JspTagException("Error getting connection: " +
e.getMessage());
}
return EVAL_BODY_BUFFERED;
}
/**
* <p>Execute the SQL statement, set either through the <code>sql</code>
* attribute or as the body, and save the result as a variable
* named by the <code>var</code> attribute in the scope specified
* by the <code>scope</code> attribute, as an object that implements
* the Result interface.
*
* <p>The connection used to execute the statement comes either
* from the <code>DataSource</code> specified by the
* <code>dataSource</code> attribute, provided by a parent action
* element, or is retrieved from a JSP scope attribute
* named <code>javax.servlet.jsptl.DataSource</code>.
*/
public int doEndTag() throws JspException {
/*
* Use the SQL statement specified by the sql attribute, if any,
* otherwise use the body as the statement.
*/
String sqlStatement = null;
if (sql != null) {
sqlStatement = sql;
}
else if (bodyContent != null) {
sqlStatement = bodyContent.getString();
}
if (sqlStatement == null || sqlStatement.trim().length() == 0) {
throw new JspTagException("No SQL statement specified");
}
int result = 0;
try {
PreparedStatement ps = conn.prepareStatement(sqlStatement);
setParameters(ps, parameters);
result = ps.executeUpdate();
}
catch (SQLException e) {
throw new JspTagException("Error processing SQL: " +
e.getMessage());
}
pageContext.setAttribute(var, new Integer(result), scope);
return SKIP_BODY;
}
/**
* Just rethrows the Throwable.
*/
public void doCatch(Throwable t) throws Throwable {
throw t;
}
/**
* Close the <code>Connection</code>, unless this action is used
* as part of a transaction.
*/
public void doFinally() {
if (conn != null && !isPartOfTransaction) {
try {
conn.close();
}
catch (SQLException e) {} // Not much we can do
}
/*
* Reset the per-invokation state.
*/
parameters = null;
isPartOfTransaction = false;
conn = null;
}
//*********************************************************************
// Private utility methods
private Connection getConnection() throws SQLException {
// Fix: Add all other mechanisms
Connection conn = null;
TransactionTag parent = (TransactionTag)
findAncestorWithClass(this, TransactionTag.class);
if (parent != null) {
conn = parent.getSharedConnection();
}
else {
conn = dataSource.getConnection();
}
return conn;
}
private void setParameters(PreparedStatement ps, List parameters)
throws SQLException {
if (parameters != null) {
for (int i = 0; i < parameters.size(); i++) {
// The first parameter has index 1
ps.setObject(i + 1, parameters.get(i));
}
}
}
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/sql/ParamTag.java
Index: ParamTag.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.tag.el.sql;
import javax.servlet.jsp.*;
import org.apache.taglibs.standard.lang.support.*;
import org.apache.taglibs.standard.tag.common.sql.ParamTagSupport;
/**
* Subclass for the JSTL library with EL support.
*
* @author Hans Bergsten
*/
public class ParamTag extends ParamTagSupport {
private String valueEL;
public void setValue(String valueEL) {
this.valueEL = valueEL;
}
public int doStartTag() throws JspException {
if (valueEL != null) {
value = (Object)
ExpressionEvaluatorManager.evaluate("value", valueEL,
Object.class, this, pageContext);
}
return super.doStartTag();
}
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/sql/QueryTag.java
Index: QueryTag.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.tag.el.sql;
import javax.sql.*;
import javax.servlet.jsp.*;
import org.apache.taglibs.standard.lang.support.*;
import org.apache.taglibs.standard.tag.common.sql.QueryTagSupport;
/**
* Subclass for the JSTL library with EL support.
*
* @author Hans Bergsten
*/
public class QueryTag extends QueryTagSupport {
private static final String MAX_ROWS =
"javax.servlet.jsp.jstl.sql.maxRows";
private String dataSourceEL;
private String sqlEL;
public void setDataSource(String dataSourceEL) {
this.dataSourceEL = dataSourceEL;
}
/**
* Setter method for the SQL statement to use for the
* query. The statement may contain parameter markers
* (question marks, ?). If so, the parameter values must
* be set using nested value elements.
*/
public void setSql(String sqlEL) {
this.sqlEL = sqlEL;
}
public int doStartTag() throws JspException {
if (dataSourceEL != null) {
dataSource = (DataSource)
ExpressionEvaluatorManager.evaluate("dataSource",
dataSourceEL, DataSource.class, this, pageContext);
}
if (sqlEL != null) {
sql = (String) ExpressionEvaluatorManager.evaluate("sql", sqlEL,
String.class, this, pageContext);
}
return super.doStartTag();
}
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/sql/TransactionTag.java
Index: TransactionTag.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.tag.el.sql;
import javax.sql.*;
import javax.servlet.jsp.*;
import org.apache.taglibs.standard.lang.support.*;
import org.apache.taglibs.standard.tag.common.sql.TransactionTagSupport;
/**
* Subclass for the JSTL library with EL support.
*
* @author Hans Bergsten
*/
public class TransactionTag extends TransactionTagSupport {
private String dataSourceEL;
public void setDataSource(String dataSourceEL) {
this.dataSourceEL = dataSourceEL;
}
public int doStartTag() throws JspException {
if (dataSourceEL != null) {
dataSource = (DataSource)
ExpressionEvaluatorManager.evaluate("dataSource",
dataSourceEL, DataSource.class, this, pageContext);
}
return super.doStartTag();
}
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/sql/UpdateTag.java
Index: UpdateTag.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.tag.el.sql;
import javax.sql.*;
import javax.servlet.jsp.*;
import org.apache.taglibs.standard.lang.support.*;
import org.apache.taglibs.standard.tag.common.sql.UpdateTagSupport;
/**
* Subclass for the JSTL library with EL support.
*
* @author Hans Bergsten
*/
public class UpdateTag extends UpdateTagSupport {
private String dataSourceEL;
private String sqlEL;
public void setDataSource(String dataSourceEL) {
this.dataSourceEL = dataSourceEL;
}
/**
* Setter method for the SQL statement to use for the
* query. The statement may contain parameter markers
* (question marks, ?). If so, the parameter values must
* be set using nested value elements.
*/
public void setSql(String sqlEL) {
this.sqlEL = sqlEL;
}
public int doStartTag() throws JspException {
if (dataSourceEL != null) {
dataSource = (DataSource)
ExpressionEvaluatorManager.evaluate("dataSource",
dataSourceEL, DataSource.class, this, pageContext);
}
if (sqlEL != null) {
sql = (String) ExpressionEvaluatorManager.evaluate("sql", sqlEL,
String.class, this, pageContext);
}
return super.doStartTag();
}
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/sql/ParamTag.java
Index: ParamTag.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.tag.rt.sql;
import javax.servlet.jsp.*;
import org.apache.taglibs.standard.lang.support.*;
import org.apache.taglibs.standard.tag.common.sql.ParamTagSupport;
/**
* Subclass for the JSTL library with rtexprvalue support.
*
* @author Hans Bergsten
*/
public class ParamTag extends ParamTagSupport {
public void setValue(Object value) {
this.value = value;
}
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/sql/QueryTag.java
Index: QueryTag.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.tag.rt.sql;
import javax.sql.*;
import javax.servlet.jsp.*;
import org.apache.taglibs.standard.lang.support.*;
import org.apache.taglibs.standard.tag.common.sql.QueryTagSupport;
/**
* Subclass for the JSTL library with rtexprvalue support.
*
* @author Hans Bergsten
*/
public class QueryTag extends QueryTagSupport {
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
/**
* Setter method for the SQL statement to use for the
* query. The statement may contain parameter markers
* (question marks, ?). If so, the parameter values must
* be set using nested value elements.
*/
public void setSql(String sql) {
this.sql = sql;
}
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/sql/TransactionTag.java
Index: TransactionTag.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.tag.rt.sql;
import javax.sql.*;
import javax.servlet.jsp.*;
import org.apache.taglibs.standard.tag.common.sql.TransactionTagSupport;
/**
* Subclass for the JSTL library with rtexprvalue support.
*
* @author Hans Bergsten
*/
public class TransactionTag extends TransactionTagSupport {
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
}
1.1 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/sql/UpdateTag.java
Index: UpdateTag.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.standard.tag.rt.sql;
import javax.sql.*;
import javax.servlet.jsp.*;
import org.apache.taglibs.standard.lang.support.*;
import org.apache.taglibs.standard.tag.common.sql.UpdateTagSupport;
/**
* Subclass for the JSTL library with rtexprvalue support.
*
* @author Hans Bergsten
*/
public class UpdateTag extends UpdateTagSupport {
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
/**
* Setter method for the SQL statement to use for the
* query. The statement may contain parameter markers
* (question marks, ?). If so, the parameter values must
* be set using nested value elements.
*/
public void setSql(String sql) {
this.sql = sql;
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>