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 / deleteunknown.js < prev    next >
Encoding:
Text File  |  2004-07-12  |  2.2 KB  |  78 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 deleteunknown.js" )
  27.  
  28. // Retrieve things from the session and request
  29. // NOTE: they are all of type java.lang.String
  30.  
  31. id      = request.getParameter( "id" )
  32.  
  33. logger.debug( "Raw" )
  34. logger.debug( "  id            [" + id + "]" )
  35.  
  36. // Actually do the database work
  37.  
  38. // We have the choice of declaring things out here and making them explicitly
  39. // null, or we have to use a different comparison in the "finally" block (defined?)
  40.  
  41. dbselector = null
  42. datasource = null
  43. conn = null
  44. addStatement = null
  45.  
  46. try
  47. {
  48.     dbselector = manager.lookup( scriptaction.DB_CONNECTION )
  49.     datasource = dbselector.select( "ceabplanner" )
  50.     conn = datasource.getConnection()    
  51.     deleteStatement = conn.prepareStatement(
  52.               "DELETE FROM otherCourses WHERE id = ?"
  53.     )
  54.  
  55.     deleteStatement.setString( 1, id ); 
  56.  
  57.     result = deleteStatement.executeUpdate()
  58.     logger.debug( "Result #1 [" + result + "]" )
  59.  
  60.     conn.commit()
  61.  
  62.     actionMap.put( "scriptaction-continue", "" )
  63. }
  64. catch( ex )
  65. {
  66.     logger.debug( "Caught Exception" )
  67.     logger.debug( "  " + ex )
  68. }
  69. finally
  70. {
  71.     if ( null != addStatement ) { addStatement.close() }
  72.     if ( null != conn ) { conn.close() }
  73.     if ( null != datasource ) { dbselector.release( datasource ) }
  74.     if ( null != dbselector ) { manager.release( dbselector ) }
  75. }
  76.  
  77. logger.debug( "END deleteunknown.js" )
  78.