Sun Java Solaris Communities My SDN Account Join SDN
 
Tutorials & Code Camps

jGuru: Help: Using executeUpdate()

 


[Exercise | API Docs | Short Course| Exercises]

Help is available for each task.



    Task 1

    In doUpdate(), retrieve the processing ResourceBundle using the input argument sargRBName; enumerate the ResourceBundle keys and get a count in the int iCount.

          // get the PropertyResourceBundle
          // for SQL update statements
          rb = ResourceBundle.getBundle( sargRBName );
          e = rb.getKeys();
    
          // Count keys - keys start at 1.
          for( ; e.hasMoreElements(); iCount++ )
          {
            (e.nextElement());
          };
    

    Task 2

    In doUpdate(), code a for loop using int i to count the number of passes and contain the current key value; On each pass, use i to create a key String and access the data for that key; Execute the retrieved SQL with executeUpdate() and get the total rows processed in int iProcessed.

          // use <= since keys start with 1
          for( int i = 1; i <= iCount; i++ )
          {
            sKey = "" + i;
            sUpdate = rb.getString( sKey );
    
            iProcessed += stmt.executeUpdate( sUpdate );
          }
    

    Task 3

    In doUpdate(), insert code to report rows processed when loop is complete.

          System.out.println( iProcessed + 
                            " rows processed." );
    

Copyright 1996-2000 jGuru.com. All Rights Reserved.