You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2004/05/05 08:10:18 UTC

cvs commit: jakarta-jetspeed-2/src/java/org/apache/jetspeed/dbutil ScriptUtil.java

taylor      2004/05/04 23:10:18

  Added:       src/java/org/apache/jetspeed/dbutil ScriptUtil.java
  Log:
  Utility to remove drop statements for Oracle
  Wish I knew a better way...
  Only required the very first time you create the DDL
  I'll document it 
  
  PR:
  Obtained from:
  Submitted by:	
  Reviewed by:	
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.1                  jakarta-jetspeed-2/src/java/org/apache/jetspeed/dbutil/ScriptUtil.java
  
  Index: ScriptUtil.java
  ===================================================================
  /*
   * Copyright 2000-2001,2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.jetspeed.dbutil;
  
  import java.io.BufferedReader;
  import java.io.File;
  import java.io.FileReader;
  import java.io.FileWriter;
  import java.io.PrintWriter;
  
  public class ScriptUtil
  {
  
      public static void main(String[] args)
      {
          System.out.println("Running DBUtils " + args[0]);
          try
          {
              if(args.length == 2 && args[0].equals("-drops"))
              {
                  dropdrops(args[1]);
              }
          }
          catch (Exception e)
          {
              e.printStackTrace();
          }
      }
      
      public static void dropdrops(String filename)
      throws Exception
      {
          System.out.println("dropping drops from " + filename);
          String outputFileName = filename + ".tmp";
          FileReader fr = new FileReader(filename);
          BufferedReader reader = new BufferedReader(fr);
          
          FileWriter fw = new FileWriter(outputFileName);
          PrintWriter writer = new PrintWriter(fw); 
          String line;
          while ((line = reader.readLine()) != null)
          {
              String temp = line.toUpperCase();
              if (!temp.startsWith("DROP"))
              {
                  writer.println(line);
              }
          }
          fr.close();
          fw.close();
          File original = new File(filename);
          File modified = new File(outputFileName);
          original.delete();
          modified.renameTo(original);
      }
      
  }
  
  

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