commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bali...@apache.org
Subject cvs commit: jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils Demo.java DemoHandler.java ProcedureUtilsTest.java
Date Mon, 10 Mar 2003 17:46:28 GMT
baliuka     2003/03/10 09:46:28

  Modified:    dbutils/src/java/org/apache/commons/dbutils
                        ProcedureUtils.java
               dbutils/src/test/org/apache/commons/dbutils Demo.java
                        DemoHandler.java ProcedureUtilsTest.java
  Log:
  removed query parameters validation from procedure utils,it will let to use extra parameters
in handler
  
  Revision  Changes    Path
  1.4       +0 -17     jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/ProcedureUtils.java
  
  Index: ProcedureUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/ProcedureUtils.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ProcedureUtils.java	9 Mar 2003 17:14:19 -0000	1.3
  +++ ProcedureUtils.java	10 Mar 2003 17:46:28 -0000	1.4
  @@ -151,23 +151,6 @@
               
           }
           
  -        for( int i = 0; i < proc.getParameterTypes().length; i++   ){
  -            if(!indexes.contains(new Integer( i + 1))){
  -                
  -                throw new IllegalArgumentException( "missing prameter " +
  -                proc.getParameterTypes()[i] +  " $" + (i + 1 ) + " in " + proc );
  -            }
  -        }
  -        
  -        for( Iterator i = indexes.iterator(); i.hasNext(); ){
  -            int param = ((Number)i.next()).intValue();
  -            if(param == 0 || param > proc.getParameterTypes().length ){
  -                throw new IllegalArgumentException( "extra prameter " +
  -                i + " in " + proc);
  -            }
  -            
  -        }
  -        
           ProcedureDescriptor descriptor = new ProcedureDescriptor();
           if(indexes.size() > 0){
               
  
  
  
  1.3       +9 -0      jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/Demo.java
  
  Index: Demo.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/Demo.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Demo.java	9 Mar 2003 17:14:19 -0000	1.2
  +++ Demo.java	10 Mar 2003 17:46:28 -0000	1.3
  @@ -42,6 +42,15 @@
       public int print();
       
       /**
  +     *@query SELECT ID, NAME FROM TBL 
  +     *@handler DemoHandler
  +     */
  +    public int print(java.io.PrintStream out) throws java.io.IOException;
  +    
  +    
  +    
  +    
  +    /**
        *@update SELECT SELECT As FROM TBL 
        *
        */
  
  
  
  1.2       +10 -6     jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/DemoHandler.java
  
  Index: DemoHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/DemoHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DemoHandler.java	9 Mar 2003 19:51:28 -0000	1.1
  +++ DemoHandler.java	10 Mar 2003 17:46:28 -0000	1.2
  @@ -11,25 +11,29 @@
       public DemoHandler() {
       }
       
  -    public Object handle(java.sql.ResultSet rs) throws java.sql.SQLException {
  +    public Object handle(java.sql.ResultSet rs, Object[] params) throws java.sql.SQLException
{
  +        java.io.PrintStream out;
  +        if(params.length > 0 && (params[params.length - 1] instanceof java.io.PrintStream)){
  +          out = (java.io.PrintStream)params[params.length - 1];
  +        }else{
  +          out = System.out;
  +        }
           int cnt = 0;
           java.sql.ResultSetMetaData rsm = rs.getMetaData();
            for(int i = 1; i <= rsm.getColumnCount(); i++ ){
  -            System.out.print(rsm.getColumnName( i ) + "\t");
  +            out.print(rsm.getColumnName( i ) + "\t");
             }
           
           while(rs.next()){
               cnt++;
  -            System.out.println();
  +            out.println();
            for(int i = 1; i <= rsm.getColumnCount(); i++ ){
  -            System.out.print( rs.getObject( i ) + "\t" );
  +            out.print( rs.getObject( i ) + "\t" );
             }
            
           }
           return new Integer(cnt);
       }
       
  -    public Object handle(java.sql.ResultSet rs, Object[] params) throws java.sql.SQLException
{
  -    }
       
   }
  
  
  
  1.3       +2 -1      jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/ProcedureUtilsTest.java
  
  Index: ProcedureUtilsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/ProcedureUtilsTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ProcedureUtilsTest.java	9 Mar 2003 17:14:19 -0000	1.2
  +++ ProcedureUtilsTest.java	10 Mar 2003 17:46:28 -0000	1.3
  @@ -54,7 +54,7 @@
           demo.create();
       }
       
  -    public void testGetInstance() {
  +    public void testGetInstance() throws Exception {
           
          Demo demo = getDemo();
          demo.clear();
  @@ -64,6 +64,7 @@
          for( int i = 0; i< 10;i++){
              demo.add(i + 2,"test" + i);
          }
  +       demo.print(System.out);
          demo.print();
          demo.clear();
        
  
  
  

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


Mime
View raw message