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


Java Database.openQuery方法代码示例

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


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

示例1: openQuery

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
/**
 * Copy information from the meta-data input to the dialog fields.
 */ 
private void openQuery()
	throws KettleException
{
	db = new Database(dbinfo);
	db.connect();
	
       // TODO add schema-name as well
	rs = db.openQuery("SELECT * FROM "+dbinfo.quoteField(tablename), null, null, ResultSet.TYPE_SCROLL_SENSITIVE);
	rowMeta = db.getReturnRowMeta();
       
	position=1;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:16,代码来源:EditDatabaseTable.java

示例2: checkResults

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
/**
 * Check the results in the target dimension table.
 * 
 * @param db database to use.
 */
public void checkResults(Database db) throws Exception
{
	String query = "SELECT ID, DLR_CD, DLR_NM, DLR_DESC FROM " +
	               target_table + " ORDER BY ID";

	String correctResults[] =  {
	    "1|BE010001|null|null",
	    "2|BE010002|null|null",
	    "3|DE010003|null|null",
	    "4|DE010004|null|null",
	};

	ResultSet rs = db.openQuery(query);
	int idx = 0;
	while (rs.next() )
	{
	   int id = rs.getInt("ID");
	   String dlr_cd = rs.getString("DLR_CD");
	   String dlr_nm = rs.getString("DLR_NM");
	   String dlr_desc = rs.getString("DLR_DESC");
	   String result = id + "|" + dlr_cd + "|" + dlr_nm + "|" + dlr_desc;
	   if ( idx > correctResults.length)
	   {
	       fail("more rows returned than expected");
	   }
	   if ( ! result.equals(correctResults[idx]))  {
		   fail("row " + (idx + 1) + " is different than expected");
	   }
	   idx++;
 	    }
 	    if ( idx < correctResults.length)
    {
       fail("less rows returned than expected");
    }
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:41,代码来源:CombinationLookupTest.java

示例3: checkResultsNormal

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
/**
 * Check the results in the target dimension table.
 * 
 * @param db database to use.
 */
public void checkResultsNormal(Database db) throws Exception
{
	String query = "SELECT ID, CODE FROM " +
	               target_table + " ORDER BY ID";

	String correctResults[] =  {
	    "100|1000",
	    "101|1001",
	    "102|1002",
	    "103|1003",
	    "104|1004",
	    "105|1005",
	    "106|1006",
	};

	ResultSet rs = db.openQuery(query);
	int idx = 0;
	while (rs.next() )
	{
	   int id = rs.getInt("ID");
	   int code = rs.getInt("CODE");
	   
	   String result = id + "|" + code;
	   if ( idx > correctResults.length)
	   {
	       fail("more rows returned than expected");
	   }
	   if ( ! result.equals(correctResults[idx]))  {
		   fail("row " + (idx + 1) + " is different than expected");
	   }
	   idx++;
 	    }
 	    if ( idx < correctResults.length)
    {
       fail("less rows returned than expected");
    }
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:43,代码来源:TableOutputTest.java

示例4: 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

示例5: 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

示例6: 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.openQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。