当前位置: 首页>>代码示例>>Java>>正文


Java Database.setQueryLimit方法代码示例

本文整理汇总了Java中org.pentaho.di.core.database.Database.setQueryLimit方法的典型用法代码示例。如果您正苦于以下问题:Java Database.setQueryLimit方法的具体用法?Java Database.setQueryLimit怎么用?Java Database.setQueryLimit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pentaho.di.core.database.Database的用法示例。


在下文中一共展示了Database.setQueryLimit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fireToDB

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
public static Object fireToDB(Context actualContext, Scriptable actualObject, Object[] ArgList, Function FunctionContext){
	
	Object oRC = new Object();
	if(ArgList.length==2){
		try{
			Object scmO = actualObject.get("_step_", actualObject);
			ScriptValuesMod scm = (ScriptValuesMod)Context.jsToJava(scmO, ScriptValuesMod.class);
			String strDBName = Context.toString(ArgList[0]);
			String strSQL = Context.toString(ArgList[1]);			
			DatabaseMeta ci = DatabaseMeta.findDatabase(scm.getTransMeta().getDatabases(), strDBName);
			ci.shareVariablesWith(scm);
		
			Database db=new Database(ci);
    		db.setQueryLimit(0);
    		try{
    			db.connect();
    			ResultSet rs = db.openQuery(strSQL);
    			ResultSetMetaData resultSetMetaData = rs.getMetaData();
				int columnCount = resultSetMetaData.getColumnCount();
				if(rs!=null){
					List<Object[]> list = new ArrayList<Object[]>(); 
					while(rs.next()){
						Object[] objRow = new Object[columnCount];
						for(int i=0;i<columnCount;i++){
							objRow[i] = rs.getObject(i+1);
						}
						list.add(objRow);
					}
					Object[][] resultArr = new Object[list.size()][];
		            list.toArray(resultArr);
		            db.disconnect();
		            return resultArr;
				}
    		}catch(Exception er){
    			throw Context.reportRuntimeError(er.toString());
    		}
		}catch(Exception e){
		}
	}else{
		throw Context.reportRuntimeError("The function call fireToDB requires 2 arguments.");	
	}
	return oRC;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:44,代码来源:ScriptValuesAddedFunctions.java

示例2: fireToDB

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
@SuppressWarnings("unused")
 public static Object fireToDB(ScriptEngine actualContext, Bindings actualObject, Object[] ArgList, Object FunctionContext){
	
	Object oRC = new Object();
	if(ArgList.length==2){
		try{
			Object scmO = actualObject.get("_step_");
			Script scm = (Script) scmO;
			String strDBName = (String) ArgList[0];
			String strSQL = (String) ArgList[1];			
			DatabaseMeta ci = DatabaseMeta.findDatabase(scm.getTransMeta().getDatabases(), strDBName);
			if(ci==null) throw new RuntimeException("Database connection not found: "+strDBName);
			ci.shareVariablesWith(scm);
		
			Database db=new Database(scm, ci);
    		db.setQueryLimit(0);
    		try{
    			 if (scm.getTransMeta().isUsingUniqueConnections())
                 {
                     synchronized (scm.getTrans()) { db.connect(scm.getTrans().getThreadName(), scm.getPartitionID()); }
                 }
                 else
                 {
                     db.connect(scm.getPartitionID());
                 }
    			
    			
    			ResultSet rs = db.openQuery(strSQL);
    			ResultSetMetaData resultSetMetaData = rs.getMetaData();
				int columnCount = resultSetMetaData.getColumnCount();
				if(rs!=null){
					List<Object[]> list = new ArrayList<Object[]>(); 
					while(rs.next()){
						Object[] objRow = new Object[columnCount];
						for(int i=0;i<columnCount;i++){
							objRow[i] = rs.getObject(i+1);
						}
						list.add(objRow);
					}
					Object[][] resultArr = new Object[list.size()][];
		            list.toArray(resultArr);
		            db.disconnect();
		            return resultArr;
				}
    		}catch(Exception er){
    			throw new RuntimeException(er.toString());
    		}
		}catch(Exception e){
			throw new RuntimeException(e.toString());
		}
	}else{
		throw new RuntimeException("The function call fireToDB requires 2 arguments.");	
	}
	return oRC;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:56,代码来源:ScriptAddedFunctions.java

示例3: fireToDB

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
@SuppressWarnings("unused")
 public static Object fireToDB(Context actualContext, Scriptable actualObject, Object[] ArgList, Function FunctionContext){
	
	Object oRC = new Object();
	if(ArgList.length==2){
		try{
			Object scmO = actualObject.get("_step_", actualObject);
			ScriptValuesMod scm = (ScriptValuesMod)Context.jsToJava(scmO, ScriptValuesMod.class);
			String strDBName = Context.toString(ArgList[0]);
			String strSQL = Context.toString(ArgList[1]);			
			DatabaseMeta ci = DatabaseMeta.findDatabase(scm.getTransMeta().getDatabases(), strDBName);
			if(ci==null) throw Context.reportRuntimeError("Database connection not found: "+strDBName);
			ci.shareVariablesWith(scm);
		
			Database db=new Database(scm, ci);
    		db.setQueryLimit(0);
    		try{
    			 if (scm.getTransMeta().isUsingUniqueConnections())
                 {
                     synchronized (scm.getTrans()) { db.connect(scm.getTrans().getThreadName(), scm.getPartitionID()); }
                 }
                 else
                 {
                     db.connect(scm.getPartitionID());
                 }
    			
    			
    			ResultSet rs = db.openQuery(strSQL);
    			ResultSetMetaData resultSetMetaData = rs.getMetaData();
				int columnCount = resultSetMetaData.getColumnCount();
				if(rs!=null){
					List<Object[]> list = new ArrayList<Object[]>(); 
					while(rs.next()){
						Object[] objRow = new Object[columnCount];
						for(int i=0;i<columnCount;i++){
							objRow[i] = rs.getObject(i+1);
						}
						list.add(objRow);
					}
					Object[][] resultArr = new Object[list.size()][];
		            list.toArray(resultArr);
		            db.disconnect();
		            return resultArr;
				}
    		}catch(Exception er){
    			throw Context.reportRuntimeError(er.toString());
    		}
		}catch(Exception e){
			throw Context.reportRuntimeError(e.toString());
		}
	}else{
		throw Context.reportRuntimeError("The function call fireToDB requires 2 arguments.");	
	}
	return oRC;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:56,代码来源:ScriptValuesAddedFunctions.java


注:本文中的org.pentaho.di.core.database.Database.setQueryLimit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。