1 33 package smallsql.database; 34 35 import java.io.*; 36 37 38 public class CommandCreateDatabase extends Command{ 39 40 41 CommandCreateDatabase( Logger log, String name ){ 42 super(log); 43 this.type = SQLTokenizer.DATABASE; 44 if(name.startsWith("file:")) 45 name = name.substring(5); 46 this.name = name; 47 } 48 49 50 void executeImpl(SSConnection con, SSStatement st) throws Exception { 51 File dir = new File( name ); 52 dir.mkdir(); 53 if(!new File(dir, Utils.MASTER_FILENAME).createNewFile()){ 54 throw Utils.createSQLException("Database '" + name + "' already exists."); 55 } 56 } 57 } | Popular Tags |