📄 xmlschema.java
字号:
.getDirectChildren(XMLNode.XML_INDEXES,XMLIndexes.NAME);
break;
case XMLNode.XML_INDEX:
result=this.getDirectChildren(XMLNode.XML_TABLES,XMLTables.NAME)
.getDirectChildren(XMLNode.XML_TABLE,path.getTable().getName())
.getDirectChildren(XMLNode.XML_INDEXES,XMLIndexes.NAME)
.getDirectChildren(XML_INDEX,path.getName());
break;
case XMLNode.XML_TRIGGERS:
result=this.getDirectChildren(XMLNode.XML_TABLES,XMLTables.NAME)
.getDirectChildren(XMLNode.XML_TABLE,path.getTable().getName())
.getDirectChildren(XMLNode.XML_TRIGGERS,XMLTriggers.NAME);
break;
case XMLNode.XML_TRIGGER:
result=this.getDirectChildren(XMLNode.XML_TABLES,XMLTables.NAME)
.getDirectChildren(XMLNode.XML_TABLE,path.getTable().getName())
.getDirectChildren(XMLNode.XML_TRIGGERS,XMLTriggers.NAME)
.getDirectChildren(XMLNode.XML_TRIGGER,path.getName());
break;
case XMLNode.XML_CONSTRAINTS:
result=this.getDirectChildren(XMLNode.XML_TABLES,XMLTables.NAME)
.getDirectChildren(XMLNode.XML_TABLE,path.getTable().getName())
.getDirectChildren(XMLNode.XML_CONSTRAINTS,XMLConstraints.NAME);
break;
case XMLNode.XML_CONSTRAINT:
result=this.getDirectChildren(XMLNode.XML_TABLES,XMLTables.NAME)
.getDirectChildren(XMLNode.XML_TABLE,path.getTable().getName())
.getDirectChildren(XMLNode.XML_CONSTRAINTS,XMLConstraints.NAME)
.getDirectChildren(XMLNode.XML_CONSTRAINT,path.getName());
break;
case XMLNode.XML_VIEWS:
result=this.getDirectChildren(XMLNode.XML_VIEWS,XMLViews.NAME);
break;
case XMLNode.XML_VIEW:
result=this.getDirectChildren(XMLNode.XML_VIEWS,XMLViews.NAME)
.getDirectChildren(XMLNode.XML_VIEW,path.getName());
break;
case XMLNode.XML_SYNONYMS:
result=this.getDirectChildren(XMLNode.XML_SYNONYMS,XMLSynonyms.NAME);
break;
case XMLNode.XML_SYNONYM:
result=this.getDirectChildren(XMLNode.XML_SYNONYMS,XMLSynonyms.NAME)
.getDirectChildren(XMLNode.XML_SYNONYM,path.getName());
break;
case XMLNode.XML_SEQUENCES:
result=this.getDirectChildren(XMLNode.XML_SEQUENCES,XMLSequences.NAME);
break;
case XMLNode.XML_SEQUENCE:
result=this.getDirectChildren(XMLNode.XML_SEQUENCES,XMLSequences.NAME)
.getDirectChildren(XMLNode.XML_SEQUENCE,path.getName());
break;
case XMLNode.XML_TYPES:
result=this.getDirectChildren(XMLNode.XML_TYPES,XMLTypes.NAME);
break;
case XMLNode.XML_ARRAYTYPES:
result=this.getDirectChildren(XMLNode.XML_TYPES,XMLTypes.NAME)
.getDirectChildren(XMLNode.XML_ARRAYTYPES,XMLArrayTypes.NAME);
break;
case XMLNode.XML_ARRAYTYPE:
result=this.getDirectChildren(XMLNode.XML_TYPES,XMLTypes.NAME)
.getDirectChildren(XMLNode.XML_ARRAYTYPES,XMLArrayTypes.NAME)
.getDirectChildren(XMLNode.XML_ARRAYTYPE,path.getName());
break;
case XMLNode.XML_OBJECTTYPES:
result=this.getDirectChildren(XMLNode.XML_TYPES,XMLTypes.NAME)
.getDirectChildren(XMLNode.XML_OBJECTTYPES,XMLObjectTypes.NAME);
break;
case XMLNode.XML_OBJECTTYPE:
result=this.getDirectChildren(XMLNode.XML_TYPES,XMLTypes.NAME)
.getDirectChildren(XMLNode.XML_OBJECTTYPES,XMLObjectTypes.NAME)
.getDirectChildren(XMLNode.XML_OBJECTTYPE,path.getName());
break;
case XMLNode.XML_TABLETYPES:
result=this.getDirectChildren(XMLNode.XML_TYPES,XMLTypes.NAME)
.getDirectChildren(XMLNode.XML_TABLETYPES,XMLTableTypes.NAME);
break;
case XMLNode.XML_TABLETYPE:
result=this.getDirectChildren(XMLNode.XML_TYPES,XMLTypes.NAME)
.getDirectChildren(XMLNode.XML_TABLETYPES,XMLTableTypes.NAME)
.getDirectChildren(XMLNode.XML_TABLETYPE,path.getName());
break;
}
return result;
}
/**将DDL语句写入文件*/
public void writeDDLToFil(File scriptFile) throws Exception {
BufferedWriter datIn=new BufferedWriter(new FileWriter(scriptFile,true));
//write tables
File tablesFile=new File(scriptFile.getParent(),this.getName()+"_tables.sql");
if((this.getDirectChildren(XMLNode.XML_TABLES,XMLTables.NAME)).isSelected()){
(this.getDirectChildren(XMLNode.XML_TABLES,XMLTables.NAME)).writeDDLToFil(tablesFile);
datIn.write("@"+this.getName()+"_tables.sql");
datIn.write("\n");
}
//write views
//System.out.println("Views isSelected:"+this.getChildren(XMLNode.XML_VIEWS,XMLViews.NAME).isSelected());
File viewsFile=new File(scriptFile.getParent(),this.getName()+"_views.sql");
if((this.getDirectChildren(XMLNode.XML_VIEWS,XMLViews.NAME)).isSelected()){
(this.getDirectChildren(XMLNode.XML_VIEWS,XMLViews.NAME)).writeDDLToFil(viewsFile);
datIn.write("@"+this.getName()+"_views.sql");
datIn.write("\n");
}
//write sequences
File sequencesFile=new File(scriptFile.getParent(),this.getName()+"_sequences.sql");
if((this.getDirectChildren(XMLNode.XML_SEQUENCES,XMLSequences.NAME)).isSelected()){
(this.getDirectChildren(XMLNode.XML_SEQUENCES,XMLSequences.NAME)).writeDDLToFil(sequencesFile);
datIn.write("@"+this.getName()+"_sequences.sql");
datIn.write("\n");
}
//write sources
File sourcesFile=new File(scriptFile.getParent(),this.getName()+"_sources.sql");
if((this.getDirectChildren(XMLNode.XML_SOURCES,XMLSources.NAME)).isSelected()){
(this.getDirectChildren(XMLNode.XML_SOURCES,XMLSources.NAME)).writeDDLToFil(sourcesFile);
datIn.write("@"+this.getName()+"_sources.sql");
datIn.write("\n");
}
//write synonyms
File synonymsFile=new File(scriptFile.getParent(),this.getName()+"_synonyms.sql");
if((this.getDirectChildren(XMLNode.XML_SYNONYMS,XMLSynonyms.NAME)).isSelected()){
(this.getDirectChildren(XMLNode.XML_SYNONYMS,XMLSynonyms.NAME)).writeDDLToFil(synonymsFile);
datIn.write("@"+this.getName()+"_synonyms.sql");
datIn.write("\n");
}
datIn.close();
}
boolean hasTables(){
return hasObjects(sqlCompareTables);
}
boolean hasViews(){
return hasObjects(sqlCompareViews);
}
boolean hasSequences(){
return hasObjects(sqlCompareSequences);
}
boolean hasSynonyms(){
return hasObjects(sqlCompareSynonyms);
}
boolean hasTypes(){
return hasObjects(sqlCompareTypes);
// return true;
}
/**实现该方法*/
boolean hasPackages(){
return hasObjects(sqlComparePackages);
// return true;
}
boolean hasProcedures(){
return hasObjects(sqlCompareProcedures);
// return true;
}
boolean hasFunctions(){
return hasObjects(sqlCompareFunctions);
// return true;
}
boolean hasObjects(String sql){
boolean result=false;
JDBCPool cnn=null;
try {
XMLDatabase db=this.getDatabase();
if(JDBCPoolManager.getInstance().isDebug())
System.out.println(this.getClass().toString());
if(db!=null) cnn = db.getConnPool();
else return false;
PreparedStatement pStmt=cnn.prepareStatement(sql);
pStmt.setString(1,this.getName());
ResultSet rs=pStmt.executeQuery();
result=false;
while(rs.next()){
if(rs.getLong(1)>0){
result=true;
break;
}
}
pStmt.close();
rs.close();
return result;
} catch (Exception e) {
e.printStackTrace();
Logger.log(Logger.ERROR,e.getMessage());
return false;
}
}
public static void main(String[] args) {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -