⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlprocedure.java

📁 导出ORACLE数据库对象DDL语句的程序
💻 JAVA
字号:
package com.icbcsdc.ddlexp.pub.xml.nodeinfo;


import java.io.InputStream;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import com.icbcsdc.ddlexp.pub.staticLog.Logger;
import com.icbcsdc.ddlexp.pub.connectionpool.JDBCCnn;
import com.icbcsdc.ddlexp.pub.connectionpool.JDBCException;
import com.icbcsdc.ddlexp.pub.connectionpool.JDBCPool;
import com.icbcsdc.ddlexp.pub.connectionpool.JDBCPoolManager;

/**
 * @author zhangyc
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
public class XMLProcedure extends XMLNode {
	
	String rsComparedProcedures="SELECT SRC_LINE,SRC_ATTR_VALUE,DST_ATTR_VALUE FROM COMPARE_PROCEDURE_LINES WHERE SRC_OWNER=?  AND SRC_PROCEDURE_NAME=? AND ATTR_NAME<>'MYSTYLE'";
	String sqlProcedure = "select line,text from DBA_SOURCE where type='PROCEDURE' and owner=? and name=? and line<1002  order by line";

	private String text="";
	//private boolean wrapped=false; 
	
	public XMLProcedure(String procName,String text,boolean wrapped){
		this.name = procName;
		this.text = text;
		this.wrapped = wrapped;
	}
	
	public XMLProcedure(String procName){
		this.name = procName;
	}

	/**
	 * @see com.icbcsdc.ddlexp.pub.xml.nodeinfo.XMLNode#getType()
	 */
	public int getType() {
		return XMLNode.XML_PROCEDURE;
	}

	/**
	 * @see com.icbcsdc.ddlexp.pub.xml.nodeinfo.XMLNode#refresh()
	 */
	public void refresh() throws Exception{
		refreshNodeNeedAccessDB();
		//refreshChangedProperties();		
	}

	/**从数据库中获取数据对象比较后的结果*/
	public void refreshChangedProperties()throws Exception{
		if(this.getCompareStatus()==XMLNode.SRC_DST_DIFF){
			/**compare_procedure_lines相关的信息放到容器changedProperties中*/
			JDBCPool cnn=null;
			//try {
			//XMLManager.getInstance().
			XMLDatabase db=this.getDatabase();
			if(db!=null) cnn = db.getConnPool();
			else return;

			//再修改比较节点
			PreparedStatement pStmt=cnn.prepareStatement(rsComparedProcedures);
			pStmt.setString(1,this.getSchema().getName().toUpperCase());
			pStmt.setString(2,this.getName().toUpperCase());
			ResultSet rsUpProcedures=pStmt.executeQuery();

			while(rsUpProcedures.next()){
				//XMLProcedure procedure1=(XMLProcedure)this.getDirectChildren(XMLNode.XML_PROCEDURE,rsUpProcedures.getString("SRC_PROCEDURE_NAME"));
				this.putChangedProperty(rsUpProcedures.getString("SRC_LINE"),rsUpProcedures.getString("SRC_ATTR_VALUE"),rsUpProcedures.getString("DST_ATTR_VALUE"));				
			}
			rsUpProcedures.close();
			pStmt.close();						
		}
	}
	
	/**从数据库中获取数据对象定义*/
	public void refreshDDLInfo() throws Exception{
		JDBCPool cnn=null;
		XMLDatabase db=this.getDatabase();
		if(db!=null) cnn = db.getConnPool();
		else return;

		if(this.isWrapped()) return;
		
		//获取Function列表
		PreparedStatement pStmt=cnn.prepareStatement(this.sqlProcedure);
		pStmt.setString(1,this.getSchema().getName().toUpperCase());
		pStmt.setString(2,this.getName());
		//pStmt.setInt(3,XMLNode.SOURCE_LINES);
		
		this.text="";
		ResultSet rsProcedure=pStmt.executeQuery();
		while(rsProcedure.next()){
			this.text= this.text +rsProcedure.getString(2);
			/**
			if(rsProcedure.getInt(1)==1){
				this.text = rsProcedure.getString(2);
				if(rsProcedure.getString(2).indexOf("wrapped") > 0){
					//是否被加密
					this.wrapped = true;
					break;
				}else{
					this.wrapped = false;
				}
			}else if(rsProcedure.getInt(1)<=XMLNode.MAX_SOURCE_LINES){
				this.text= this.text +rsProcedure.getString(2);
			}else{
				this.overflow=true;
				break;
			}
			**/
		}
		
		//Logger.log(Logger.DEBUG,"XMLProcedure refreshDDLInfo:"+this.getText());
		rsProcedure.close();
		pStmt.close();			
	
	}


	/**
	 * @see com.icbcsdc.ddlexp.pub.xml.nodeinfo.XMLNode#chkChildType(XMLNode)
	 */
	public boolean chkChildType(XMLNode node) {
		return false;
	}

	/**
	 * @see com.icbcsdc.ddlexp.pub.xml.nodeinfo.XMLNode#getXmlStream()
	public InputStream getXmlStream() {
		return null;
	}
	 */

	/**
	 * @see com.icbcsdc.ddlexp.pub.xml.nodeinfo.XMLNode#getSqlDDL()
	 */
	public String getSqlDDL() {
		//return this.getSchemaDDLStr();
		return text;

	}

	public static void main(String[] args) {
	}


	/**
	 * @return Returns the text.
	 */
	public String getText() {
		if(this.overflow){
			return XMLNode.overMaxLines;
		}else
			return text;
	}
	/**
	 * @return Returns the wrapped.
	public boolean isWrapped() {
		return wrapped;
	}
	 */
	/**
	 * Sets the wrapped.
	 * @param wrapped The wrapped to set
	public void setWrapped(boolean wrapped) {
		this.wrapped = wrapped;
	}
	 */

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -