home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / deleteknown.js < prev    next >
Encoding:
Text File  |  2004-07-12  |  2.6 KB  |  83 lines

  1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. *     http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. // Step 1 -- Retrieve helper "beans" from the BSF framework
  17.  
  18. scriptaction = bsf.lookupBean( "scriptaction" )
  19. manager      = bsf.lookupBean( "manager" )            
  20. request      = bsf.lookupBean( "request" )
  21. logger       = bsf.lookupBean( "logger" )
  22. actionMap    = bsf.lookupBean( "actionMap" )
  23.  
  24. // Step 2 -- Perform the action
  25.  
  26. logger.debug( "START deleteknown.js" )
  27.  
  28. // Retrieve things from the session and request
  29. // NOTE: they are all of type java.lang.String
  30.  
  31. session = request.getSession( false )
  32. uwid     = session.getAttribute( "uwid" )
  33. id     = request.getParameter( "id" )
  34.  
  35. logger.debug( "Raw" )
  36. logger.debug( "  uwid          [" + uwid + "]" )
  37. logger.debug( "  id            [" + id + "]" )
  38.  
  39. // Actually do the database work
  40.  
  41. // We have the choice of declaring things out here and making them explicitly
  42. // null, or we have to use a different comparison in the "finally" block (defined?)
  43.  
  44. dbselector = null
  45. datasource = null
  46. conn = null
  47. addStatement = null
  48.  
  49. try
  50. {
  51.     dbselector = manager.lookup( scriptaction.DB_CONNECTION )
  52.     datasource = dbselector.select( "ceabplanner" )
  53.     conn = datasource.getConnection()    
  54.     deleteStatement = conn.prepareStatement(
  55.         "DELETE FROM studentknowncourselist WHERE student = ( SELECT id FROM students WHERE uw_userid = ? ) AND known_course = ?"
  56.     )
  57.  
  58.     deleteStatement.setString( 1, uwid ); 
  59.     deleteStatement.setString( 2, id ); 
  60.  
  61.     result = deleteStatement.executeUpdate()
  62.     logger.debug( "Result #1 [" + result + "]" )
  63.  
  64.     conn.commit()
  65.  
  66.     actionMap.put( "scriptaction-continue", "" )
  67.     session.setAttribute( "results", "<SUCCESS>Course deleted at " + Date() + "</SUCCESS>" )
  68. }
  69. catch( ex )
  70. {
  71.     logger.debug( "Caught Exception" )
  72.     logger.debug( "  " + ex )
  73. }
  74. finally
  75. {
  76.     if ( null != addStatement ) { addStatement.close() }
  77.     if ( null != conn ) { conn.close() }
  78.     if ( null != datasource ) { dbselector.release( datasource ) }
  79.     if ( null != dbselector ) { manager.release( dbselector ) }
  80. }
  81.  
  82. logger.debug( "END deleteknown.js" )
  83.