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

📄 createpoolcommand.java

📁 与postgresql数据库结合的数据库水印软件包
💻 JAVA
字号:
/* *  * Copyright 2003,2004 The Watermill Team * * This file is part of Watermill. * *    Watermill is free software; you can redistribute it and/or modify *    it under the terms of the GNU General Public License as published by *    the Free Software Foundation; either version 2 of the License, or *    (at your option) any later version. * *    Watermill is distributed in the hope that it will be useful, *    but WITHOUT ANY WARRANTY; without even the implied warranty of *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *    GNU General Public License for more details. * *    You should have received a copy of the GNU General Public License *    along with Watermill; if not, write to the Free Software *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * */package Watermill.rmill;import Watermill.relational.*;import Watermill.kernel.*;import java.util.*;import java.sql.*;public class CreatePoolCommand extends Command {    private String poolName;    private String dbName;    private LocalConstraints localConstraints;    private GlobalConstraints globalConstraints;    private GroupGlobalConstraints groupGlobalConstraints;    public String poolType;    public CreatePoolCommand(String poolName,String dbName,LocalConstraints localConstraints,GlobalConstraints globalConstraints,GroupGlobalConstraints groupGlobalConstraints,String poolType){	this.poolName=poolName;	this.dbName=dbName;	this.localConstraints=localConstraints;	this.globalConstraints=globalConstraints;	this.groupGlobalConstraints=groupGlobalConstraints;	this.poolType=poolType;    }    public String toString(){	return "CreatePoolCommand for "+poolName+" on "+dbName+" with "+localConstraints.toString()+", global "+globalConstraints.toString()+" and group global "+groupGlobalConstraints.toString();    }    public void transformGroupConstraints(Document d){	for(Enumeration e=groupGlobalConstraints.elements();e.hasMoreElements();){	    transformGroupConstraint(d,(GroupGlobalConstraint)e.nextElement());	}    }        public void transformGroupConstraint(Document d,GroupGlobalConstraint gc){	DB db=(DB)d;	Msg.debug("Transforming constraint "+gc.toString());	try {	    Connection connection=db.getConnection();	    Statement stm = connection.createStatement();	    	    ResultSet rs = stm.executeQuery(gc.generator);	    	    while(rs.next()){		String id=rs.getString(1);				GlobalConstraint res=new GlobalConstraint(gc.gc);		res.condition=res.condition.replaceAll("\\$ID",id);		Msg.debug("Adding new global constraint "+res);		globalConstraints.add(res);	    }	}	catch (Exception e){	    Msg.fatal(e);	}    }	    public void execute(Manager m){	Msg.debug(toString());	    	Chrono.reset();	Document d=new DB(dbName,Constant.masterDBuser,Constant.masterDBpassword);		    		Msg.debug("Transforming Group constraints");	transformGroupConstraints(d);	Schema s=d.getSchema();	WSchema ws=new WSchema(s,localConstraints,globalConstraints);	Pool p=null;	if (poolType.equals("wi"))	    p=new WIPool(poolName,d,ws);	else	    if (poolType.equals("greedy"))		p=new GreedyPool(poolName,d,ws);	    else { // default		Msg.println("Unknown pool type "+poolType+", switching to default greedy pool.");		p=new GreedyPool(poolName,d,ws);	    }	m.pools.add(p);	Msg.println("CREATE POOL");    }}

⌨️ 快捷键说明

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