1 11 12 package com.nilostep.xlsql.sql; 13 14 import com.nilostep.xlsql.database.xlDatabase; 15 import com.nilostep.xlsql.database.*; 16 17 import java.sql.*; 18 19 24 public class xlSqlRenameTable implements xlSqlCommand { 25 27 protected com.nilostep.xlsql.database.xlDatabase db; 28 protected String _schema; 29 protected String _table; 30 protected String _schema_old; 31 protected String _table_old; 32 33 41 public xlSqlRenameTable(com.nilostep.xlsql.database.xlDatabase database, String schema, String table, 42 String schema_old, String table_old) { 43 if (database == null) { 44 throw new NullPointerException ("xlSQL: database null"); 45 } else { 46 db = database; 47 } 48 49 if (schema == null) { 50 throw new NullPointerException ("xlSQL: schema null"); 51 } else { 52 _schema = schema; 53 } 54 55 if (table == null) { 56 throw new NullPointerException ("xlSQL: table null"); 57 } else { 58 _table = table; 59 } 60 61 if (schema_old == null) { 62 throw new NullPointerException ("xlSQL: schema_old null"); 63 } else { 64 _schema_old = schema_old; 65 } 66 67 if (table_old == null) { 68 throw new NullPointerException ("xlSQL: table_old null"); 69 } else { 70 _table_old = table_old; 71 } 72 } 73 74 81 public boolean execAllowed() throws SQLException { 82 boolean ret = true; 83 if (db.tableExists(_schema, _table)) { 84 ret = false; 85 } 86 return ret; 87 } 88 89 94 public void execute() throws SQLException { 95 db.removeTable(_schema_old, _table_old); 96 db.addSchema(_schema); 97 db.addTable(_schema, _table); 98 } 99 } | Popular Tags |