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 2002/01/31 23:56:27 UTC

cvs commit: jakarta-taglibs/standard/examples/web/sql Update.jsp Transaction.jsp QueryParam.jsp QueryIterate.jsp QueryDirect.jsp

horwat      02/01/31 14:56:27

  Modified:    standard/src/org/apache/taglibs/standard/tag/common/sql
                        QueryTagSupport.java RowImpl.java
                        UpdateTagSupport.java
               standard/src/javax/servlet/jsp/jstl/sql Row.java
               standard/src/org/apache/taglibs/standard/resources
                        Resources.properties
               standard/examples/web/sql Update.jsp Transaction.jsp
                        QueryParam.jsp QueryIterate.jsp QueryDirect.jsp
  Log:
  Changes to comply with revised spec:
          - <sql:query>: startRow follows 0-based indexing
          - <sql:query>/<sql:update>: if dataSource specified, must not be nested inside an <sql:transaction>
          - Row interface: when getting value of a column, return the Object itself and not the Column object
  
  Revision  Changes    Path
  1.6       +11 -4     jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/QueryTagSupport.java
  
  Index: QueryTagSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/QueryTagSupport.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- QueryTagSupport.java	16 Jan 2002 02:22:20 -0000	1.5
  +++ QueryTagSupport.java	31 Jan 2002 22:56:27 -0000	1.6
  @@ -116,7 +116,7 @@
   
       private void init() {
           scope = PageContext.PAGE_SCOPE;
  -        startRow = 1;
  +        startRow = 0;
   
           try {
               maxRows = Integer.parseInt(
  @@ -282,6 +282,7 @@
   	parameters = null;
   	isPartOfTransaction = false;
   	conn = null;
  +        dataSource = null;
       }
   
       //*********************************************************************
  @@ -305,18 +306,24 @@
           }
           else {
               ServletContext application = pageContext.getServletContext();
  -            dataSource = (DataSource) pageContext.findAttribute(
  -                application.getInitParameter(DATASOURCE));
  +            if (application.getInitParameter(DATASOURCE) != null) {
  +                dataSource = (DataSource) pageContext.findAttribute(
  +                    application.getInitParameter(DATASOURCE));
  +            }
           }
       }
   
   
  -    private Connection getConnection() throws SQLException {
  +    private Connection getConnection() throws JspException, SQLException {
   	// Fix: Add all other mechanisms
   	Connection conn = null;
   	TransactionTagSupport parent = (TransactionTagSupport) 
   	    findAncestorWithClass(this, TransactionTagSupport.class);
   	if (parent != null) {
  +            if (dataSource != null) {
  +                throw new JspTagException(
  +                    Resources.getMessage("ERROR_NESTED_DATASOURCE"));
  +            }
   	    conn = parent.getSharedConnection();
               isPartOfTransaction = true;
   	}
  
  
  
  1.3       +8 -8      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/RowImpl.java
  
  Index: RowImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/RowImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RowImpl.java	19 Dec 2001 01:48:58 -0000	1.2
  +++ RowImpl.java	31 Jan 2002 22:56:27 -0000	1.3
  @@ -80,18 +80,18 @@
       }
   
       /**
  -     * Returns the Column object for the named column
  +     * Returns the Object value 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
  +     * @return the Object at the named column
        */
  -    public Column get(String name) {
  +    public Object get(String name) {
   	for (int i=0; i < columns.length; i++) {
               try {
   	        if (name.equalsIgnoreCase(columns[i].getName())) {
  -	            return columns[i];
  +	            return columns[i].getValue();
                   }
               } catch (SQLException ex) {
                   // can't get the column
  @@ -101,15 +101,15 @@
       }
   
       /**
  -     * Returns the Column for the given column index
  +     * Returns the Object value for the given column index
        *
        * @param index the index of the column
        *
  -     * @return the Column object of the indexed column
  +     * @return the Object at the indexed column
        */
  -    public Column get(int index) {
  +    public Object get(int index) {
           if ((index >= 0) && (index < columns.length)) {
  -	    return columns[index];
  +	    return columns[index].getValue();
           }
           return null;
       }
  
  
  
  1.7       +10 -3     jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/UpdateTagSupport.java
  
  Index: UpdateTagSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/UpdateTagSupport.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- UpdateTagSupport.java	16 Jan 2002 02:22:20 -0000	1.6
  +++ UpdateTagSupport.java	31 Jan 2002 22:56:27 -0000	1.7
  @@ -234,6 +234,7 @@
   	parameters = null;
   	isPartOfTransaction = false;
   	conn = null;
  +        dataSource = null;
       }
   
       //*********************************************************************
  @@ -257,17 +258,23 @@
           }
           else {
               ServletContext application = pageContext.getServletContext();
  -            dataSource = (DataSource) pageContext.findAttribute(
  -                application.getInitParameter(DATASOURCE));
  +            if (application.getInitParameter(DATASOURCE) != null) {
  +                dataSource = (DataSource) pageContext.findAttribute(
  +                    application.getInitParameter(DATASOURCE));
  +            }
           }
       }
   
  -    private Connection getConnection() throws SQLException {
  +    private Connection getConnection() throws JspException, SQLException {
   	// Fix: Add all other mechanisms
   	Connection conn = null;
   	TransactionTagSupport parent = (TransactionTagSupport) 
   	    findAncestorWithClass(this, TransactionTagSupport.class);
   	if (parent != null) {
  +            if (dataSource != null) {
  +                throw new JspTagException(
  +                    Resources.getMessage("ERROR_NESTED_DATASOURCE"));
  +            }
   	    conn = parent.getSharedConnection();
               isPartOfTransaction = true;
   	}
  
  
  
  1.2       +4 -4      jakarta-taglibs/standard/src/javax/servlet/jsp/jstl/sql/Row.java
  
  Index: Row.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/javax/servlet/jsp/jstl/sql/Row.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Row.java	11 Dec 2001 22:10:34 -0000	1.1
  +++ Row.java	31 Jan 2002 22:56:27 -0000	1.2
  @@ -64,16 +64,16 @@
   public interface Row {
   
       /**
  -     * Returns the Column object for the named column
  +     * Returns the Object at the named column
        *
        */
  -    public Column get(String name);
  +    public Object get(String name);
   
       /**
  -     * Returns the Column for the given column index
  +     * Returns the Object at the given column index
        *
        */
  -    public Column get(int index);
  +    public Object get(int index);
   
       /**
        * Returns an array Column objects
  
  
  
  1.9       +3 -0      jakarta-taglibs/standard/src/org/apache/taglibs/standard/resources/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/resources/Resources.properties,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Resources.properties	25 Jan 2002 19:21:57 -0000	1.8
  +++ Resources.properties	31 Jan 2002 22:56:27 -0000	1.9
  @@ -157,6 +157,9 @@
   ERROR_GET_CONNECTION=\
       Error getting connection: "{0}"
   
  +ERROR_NESTED_DATASOURCE=\
  +    It is illegal to specify a DataSource when nested within a &lt;transaction&gt;
  +
   SQL_NO_STATEMENT=\
       No SQL statement specified
   
  
  
  
  1.5       +5 -5      jakarta-taglibs/standard/examples/web/sql/Update.jsp
  
  Index: Update.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/examples/web/sql/Update.jsp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Update.jsp	16 Jan 2002 22:43:51 -0000	1.4
  +++ Update.jsp	31 Jan 2002 22:56:27 -0000	1.5
  @@ -22,7 +22,7 @@
   
   <sql:transaction dataSource="$example">
   
  -  <sql:update var="newTable" dataSource="$example">
  +  <sql:update var="newTable">
       create table mytable (
         nameid int primary key,
         name varchar(80)
  @@ -30,20 +30,20 @@
     </sql:update>
   
   <h2>Inserting three rows into table</h2>
  -  <sql:update var="updateCount" dataSource="$example">
  +  <sql:update var="updateCount">
       INSERT INTO mytable VALUES (1,'Paul Oakenfold')
     </sql:update>
  -  <sql:update var="updateCount" dataSource="$example">
  +  <sql:update var="updateCount">
       INSERT INTO mytable VALUES (2,'Timo Maas')
     </sql:update>
  -  <sql:update var="updateCount" dataSource="$example">
  +  <sql:update var="updateCount">
       INSERT INTO mytable VALUES (3,'Paul van Dyk')
     </sql:update>
   
   <p>DONE: Inserting three rows into table</p>
   
   
  -  <sql:query var="deejays" dataSource="$example">
  +  <sql:query var="deejays">
       SELECT * FROM mytable
     </sql:query>
   
  
  
  
  1.4       +4 -4      jakarta-taglibs/standard/examples/web/sql/Transaction.jsp
  
  Index: Transaction.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/examples/web/sql/Transaction.jsp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Transaction.jsp	16 Jan 2002 22:43:51 -0000	1.3
  +++ Transaction.jsp	31 Jan 2002 22:56:27 -0000	1.4
  @@ -22,7 +22,7 @@
   <h2>Dropping table and creating table using a transaction</h2>
   
   <sql:transaction dataSource="$example">
  -  <sql:update var="newTable" dataSource="$example">
  +  <sql:update var="newTable">
       create table mytable (
         nameid int primary key,
         name varchar(80)
  @@ -37,13 +37,13 @@
   <h2>Populating table in one transaction</h2>
   
   <sql:transaction dataSource="$example">
  -  <sql:update var="updateCount" dataSource="$example">
  +  <sql:update var="updateCount">
       INSERT INTO mytable VALUES (1,'Paul Oakenfold')
     </sql:update>
  -  <sql:update var="updateCount" dataSource="$example">
  +  <sql:update var="updateCount">
       INSERT INTO mytable VALUES (2,'Timo Maas')
     </sql:update>
  -  <sql:update var="updateCount" dataSource="$example">
  +  <sql:update var="updateCount">
       INSERT INTO mytable VALUES (3,'Paul van Dyk')
     </sql:update>
   </sql:transaction>
  
  
  
  1.5       +7 -7      jakarta-taglibs/standard/examples/web/sql/QueryParam.jsp
  
  Index: QueryParam.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/examples/web/sql/QueryParam.jsp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- QueryParam.jsp	16 Jan 2002 22:43:51 -0000	1.4
  +++ QueryParam.jsp	31 Jan 2002 22:56:27 -0000	1.5
  @@ -24,31 +24,31 @@
   
   <sql:transaction dataSource="$example">
   
  -  <sql:update var="newTable" dataSource="$example">
  +  <sql:update var="newTable">
       create table mytable (
         nameid int primary key,
         name varchar(80)
       )
     </sql:update>
   
  -  <sql:update var="updateCount" dataSource="$example">
  +  <sql:update var="updateCount">
       INSERT INTO mytable VALUES (1,'Paul Oakenfold')
     </sql:update>
   
  -  <sql:update var="updateCount" dataSource="$example">
  +  <sql:update var="updateCount">
       INSERT INTO mytable VALUES (?,'Timo Maas')
         <sql:param value="2"/>
     </sql:update>
   
  -  <sql:update var="updateCount" dataSource="$example">
  +  <sql:update var="updateCount">
       INSERT INTO mytable VALUES (?,?)
         <sql:param value="3"/>
         <sql:param value="$newName"/>
     </sql:update>
   
  -<sql:query var="deejay" dataSource="$example">
  -  SELECT * FROM mytable
  -</sql:query>
  +  <sql:query var="deejay">
  +    SELECT * FROM mytable
  +  </sql:query>
   
   </sql:transaction>
   
  
  
  
  1.5       +5 -5      jakarta-taglibs/standard/examples/web/sql/QueryIterate.jsp
  
  Index: QueryIterate.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/examples/web/sql/QueryIterate.jsp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- QueryIterate.jsp	16 Jan 2002 22:43:51 -0000	1.4
  +++ QueryIterate.jsp	31 Jan 2002 22:56:27 -0000	1.5
  @@ -20,25 +20,25 @@
   
   <sql:transaction dataSource="$example">
   
  -  <sql:update var="newTable" dataSource="$example">
  +  <sql:update var="newTable">
       create table mytable (
         nameid int primary key,
         name varchar(80)
       )
     </sql:update>
   
  -  <sql:update var="updateCount" dataSource="$example">
  +  <sql:update var="updateCount">
       INSERT INTO mytable VALUES (1,'Paul Oakenfold')
     </sql:update>
  -  <sql:update var="updateCount" dataSource="$example">
  +  <sql:update var="updateCount">
       INSERT INTO mytable VALUES (2,'Timo Maas')
     </sql:update>
  -  <sql:update var="updateCount" dataSource="$example">
  +  <sql:update var="updateCount">
       INSERT INTO mytable VALUES (3,'Paul van Dyk')
     </sql:update>
   
   
  -  <sql:query var="deejays" dataSource="$example">
  +  <sql:query var="deejays">
       SELECT * FROM mytable
     </sql:query>
   
  
  
  
  1.5       +5 -5      jakarta-taglibs/standard/examples/web/sql/QueryDirect.jsp
  
  Index: QueryDirect.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/examples/web/sql/QueryDirect.jsp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- QueryDirect.jsp	16 Jan 2002 22:43:51 -0000	1.4
  +++ QueryDirect.jsp	31 Jan 2002 22:56:27 -0000	1.5
  @@ -21,24 +21,24 @@
   
   <sql:transaction dataSource="$example">
   
  -  <sql:update var="newTable" dataSource="$example">
  +  <sql:update var="newTable">
       create table mytable (
         nameid int primary key,
         name varchar(80)
       )
     </sql:update>
   
  -  <sql:update var="updateCount" dataSource="$example">
  +  <sql:update var="updateCount">
       INSERT INTO mytable VALUES (1,'Paul Oakenfold')
     </sql:update>
  -  <sql:update var="updateCount" dataSource="$example">
  +  <sql:update var="updateCount">
       INSERT INTO mytable VALUES (2,'Timo Maas')
     </sql:update>
  -  <sql:update var="updateCount" dataSource="$example">
  +  <sql:update var="updateCount">
       INSERT INTO mytable VALUES (3,'Paul van Dyk')
     </sql:update>
   
  -  <sql:query var="deejays" dataSource="$example">
  +  <sql:query var="deejays">
       SELECT * FROM mytable
     </sql:query>
   
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>