commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/sql UpdateTag.java QueryTag.java
Date Thu, 30 May 2002 14:58:31 GMT
jstrachan    02/05/30 07:58:30

  Modified:    jelly/src/java/org/apache/commons/jelly/tags/sql
                        UpdateTag.java QueryTag.java
  Log:
  Applied patch suggested by Hristo to use a Statement rather than a PreparedStatement when
no parameters are being used which can perform quicker on some JDBC drivers
  
  Revision  Changes    Path
  1.4       +9 -3      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/sql/UpdateTag.java
  
  Index: UpdateTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/sql/UpdateTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- UpdateTag.java	17 May 2002 15:18:09 -0000	1.3
  +++ UpdateTag.java	30 May 2002 14:58:30 -0000	1.4
  @@ -182,9 +182,15 @@
   
           int result = 0;
           try {
  -            PreparedStatement ps = conn.prepareStatement(sqlStatement);
  -            setParameters(ps, parameters);
  -            result = ps.executeUpdate();
  +            if ( parameters == null || parameters.size() == 0 ) {
  +                Statement statement = conn.createStatement();
  +                result = statement.executeUpdate(sqlStatement);
  +            }
  +            else {
  +                PreparedStatement ps = conn.prepareStatement(sqlStatement);
  +                setParameters(ps, parameters);
  +                result = ps.executeUpdate();
  +            }
               if (var != null) {
                   context.setVariable(var, new Integer(result));
               }
  
  
  
  1.8       +10 -4     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/sql/QueryTag.java
  
  Index: QueryTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/sql/QueryTag.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- QueryTag.java	21 May 2002 19:36:56 -0000	1.7
  +++ QueryTag.java	30 May 2002 14:58:30 -0000	1.8
  @@ -251,14 +251,20 @@
                * value for isLimitedByMaxRows(); there's no way to check
                * if it was from the ResultSet.
                */
  -            PreparedStatement ps = conn.prepareStatement(sqlStatement);
  -            setParameters(ps, parameters);
  -            
               if ( log.isDebugEnabled() ) {
                   log.debug( "About to execute query: " + sqlStatement );
               }
               
  -            ResultSet rs = ps.executeQuery();
  +            ResultSet rs = null;
  +            if ( parameters == null || parameters.size() == 0 ) {
  +                Statement statement = conn.createStatement();
  +                rs = statement.executeQuery(sqlStatement);
  +            }
  +            else {
  +                PreparedStatement ps = conn.prepareStatement(sqlStatement);
  +                setParameters(ps, parameters);            
  +                rs = ps.executeQuery();
  +            }
               
               result = new ResultImpl(rs, startRow, maxRows);
               context.setVariable(var, result);
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message