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


Java ParameterMetaData.getParameterCount方法代码示例

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


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

示例1: parameters

import java.sql.ParameterMetaData; //导入方法依赖的package包/类
/**
 * Converts from JDBC metadata to Avatica parameters
 */
protected static List<AvaticaParameter> parameters(ParameterMetaData metaData)
    throws SQLException {
  if (metaData == null) {
    return Collections.emptyList();
  }
  final List<AvaticaParameter> params = new ArrayList<>();
  for (int i = 1; i <= metaData.getParameterCount(); i++) {
    params.add(
        new AvaticaParameter(metaData.isSigned(i), metaData.getPrecision(i),
            metaData.getScale(i), metaData.getParameterType(i),
            metaData.getParameterTypeName(i),
            metaData.getParameterClassName(i), "?" + i));
  }
  return params;
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:19,代码来源:JdbcMeta.java

示例2: sendParameterDescription

import java.sql.ParameterMetaData; //导入方法依赖的package包/类
private void sendParameterDescription(Prepared p) throws IOException {
    try {
        PreparedStatement prep = p.prep;
        ParameterMetaData meta = prep.getParameterMetaData();
        int count = meta.getParameterCount();
        startMessage('t');
        writeShort(count);
        for (int i = 0; i < count; i++) {
            int type;
            if (p.paramType != null && p.paramType[i] != 0) {
                type = p.paramType[i];
            } else {
                type = PgServer.PG_TYPE_VARCHAR;
            }
            server.checkType(type);
            writeInt(type);
        }
        sendMessage();
    } catch (Exception e) {
        sendErrorResponse(e);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:23,代码来源:PgServerThread.java

示例3: assertStatementState

import java.sql.ParameterMetaData; //导入方法依赖的package包/类
private void assertStatementState(int[] parameterExpectedValues, 
    int[] expectedValues, Statement s) 
throws SQLException {
    assertEquals(expectedValues[0], s.getResultSetType());
    assertEquals(
        expectedValues[1], s.getResultSetConcurrency());
    assertEquals(
        expectedValues[2], s.getFetchDirection());
    assertEquals(expectedValues[3], s.getFetchSize());
    assertEquals(expectedValues[4], s.getMaxFieldSize());
    assertEquals(expectedValues[5], s.getMaxRows());
    assertEquals(expectedValues[6], s.getResultSetHoldability());

    if (s instanceof PreparedStatement) {
        PreparedStatement ps = (PreparedStatement) s;
        ParameterMetaData psmd = ps.getParameterMetaData();
        // Parameter count:
        assertEquals(parameterExpectedValues[0], psmd.getParameterCount());
        for (int i = 1; i <= psmd.getParameterCount(); i++) {
            assertEquals(parameterExpectedValues[i], psmd.getParameterType(i));
        }
    }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:24,代码来源:J2EEDataSourceTest.java

示例4: testParameterMetaData

import java.sql.ParameterMetaData; //导入方法依赖的package包/类
/**
        * tests parameterMetaData and reports error if the ParameterMetaData results
 * does not match the expected results.
        *
        * @param paramMetaData ParameterMetadata object
 * @param paramMetaDataArray 2 dimensional array containing expected test results. 
 * @exception SQLException if any error occurs
        */
static void testParameterMetaData(ParameterMetaData paramMetaData, String [][] paramMetaDataArray) throws SQLException {
	int numParam = paramMetaData.getParameterCount();
	
	for (int i=0, j=0; i<numParam; i++) {	
                      	assertEquals("Unexpected parameter isNullable", paramMetaDataArray[i][j++], parameterIsNullableInStringForm(paramMetaData.isNullable(i+1)));
                      	assertEquals("Unexpected parameter isSigned", Boolean.valueOf(paramMetaDataArray[i][j++]).booleanValue(), paramMetaData.isSigned(i+1));
                      	assertEquals("Unexpected parameter getPrecision", Integer.parseInt(paramMetaDataArray[i][j++]) ,  paramMetaData.getPrecision(i+1));
                      	assertEquals("Unexpected parameter getScale", Integer.parseInt(paramMetaDataArray[i][j++]) , paramMetaData.getScale(i+1));
                      	assertEquals("Unexpected parameter getParameterType", Integer.parseInt(paramMetaDataArray[i][j++]) , paramMetaData.getParameterType(i+1));
                      	assertEquals("Unexpected parameter getParameterTypeName", paramMetaDataArray[i][j++] , paramMetaData.getParameterTypeName(i+1));
                      	assertEquals("Unexpected parameter getParameterClassName", paramMetaDataArray[i][j++] , paramMetaData.getParameterClassName(i+1));
                      	assertEquals("Unexpected parameter getParameterMode", paramMetaDataArray[i][j++] , parameterModeInStringForm(paramMetaData.getParameterMode(i+1)));
		
		j=0;
	}
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:25,代码来源:ParameterMetaDataJdbc30Test.java

示例5: getParameterResultSet

import java.sql.ParameterMetaData; //导入方法依赖的package包/类
private static String getParameterResultSet(ParameterMetaData meta)
        throws SQLException {
    StringBuilder buff = new StringBuilder();
    if (meta == null) {
        return "No parameter meta data";
    }
    buff.append("<table cellspacing=0 cellpadding=0>").
        append("<tr><th>className</th><th>mode</th><th>type</th>").
        append("<th>typeName</th><th>precision</th><th>scale</th></tr>");
    for (int i = 0; i < meta.getParameterCount(); i++) {
        buff.append("</tr><td>").
            append(meta.getParameterClassName(i + 1)).
            append("</td><td>").
            append(meta.getParameterMode(i + 1)).
            append("</td><td>").
            append(meta.getParameterType(i + 1)).
            append("</td><td>").
            append(meta.getParameterTypeName(i + 1)).
            append("</td><td>").
            append(meta.getPrecision(i + 1)).
            append("</td><td>").
            append(meta.getScale(i + 1)).
            append("</td></tr>");
    }
    buff.append("</table>");
    return buff.toString();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:28,代码来源:WebApp.java

示例6: testDataAwareProcedureWithoutResultSets

import java.sql.ParameterMetaData; //导入方法依赖的package包/类
public void testDataAwareProcedureWithoutResultSets()
throws Exception {
  
  setup();
  CallableStatement cs = prepareCall("CALL PROCEDURE_WITHOUT_RESULTSET(?, ?) ON TABLE EMP.PARTITIONTESTTABLE WHERE SECONDID=4 AND THIRDID='3'");
  cs.registerOutParameter(2, java.sql.Types.VARCHAR, 20);
  int number=2;
  String name="INOUTPARAMETER";
  cs.setInt(1, number);
  cs.setString(2, name);
 
  
  cs.execute();
  
  ResultSet rs=cs.getResultSet();
  if(rs!=null || cs.getMoreResults()) {
    fail("no dynamic result set for the procedure!");
  }
  
  ParameterMetaData pmd=cs.getParameterMetaData();  
  int numParameters=pmd.getParameterCount();
  assertTrue(" the number of parameter is 2", numParameters==2);
  try {
    cs.getInt(1);
    fail("the in parameteter cannot be read!");
  } catch (Exception e) {
    
  }
  Object parameter2=cs.getObject(2);    
  assertTrue("the second inout parameter is "+name+number, parameter2.equals(name+number));
    
  

}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:35,代码来源:ProcedureTestDUnit.java

示例7: testDataAwareProcedureWithoutResultSetsUsingGlobalIndex

import java.sql.ParameterMetaData; //导入方法依赖的package包/类
public void testDataAwareProcedureWithoutResultSetsUsingGlobalIndex()
throws Exception {
  
  setup();
  CallableStatement cs = prepareCall("CALL PROCEDURE_WITHOUT_RESULTSET(?, ?) ON TABLE EMP.PARTITIONTESTTABLE1 WHERE SECONDID=4 AND THIRDID='3'");
  cs.registerOutParameter(2, java.sql.Types.VARCHAR, 20);
  int number=2;
  String name="INOUTPARAMETER";
  cs.setInt(1, number);
  cs.setString(2, name);
 
  
  cs.execute();
  
  ResultSet rs=cs.getResultSet();
  if(rs!=null || cs.getMoreResults()) {
    fail("no dynamic result set for the procedure!");
  }
  
  ParameterMetaData pmd=cs.getParameterMetaData();  
  int numParameters=pmd.getParameterCount();
  assertTrue(" the number of parameter is 2", numParameters==2);
  try {
    cs.getInt(1);
    fail("the in parameteter cannot be read!");
  } catch (Exception e) {
    
  }
  Object parameter2=cs.getObject(2);    
  assertTrue("the second inout parameter is "+name+number, parameter2.equals(name+number));
    
  

}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:35,代码来源:ProcedureTestDUnit.java

示例8: testDataAwareProcedureWithoutResultSets

import java.sql.ParameterMetaData; //导入方法依赖的package包/类
public void testDataAwareProcedureWithoutResultSets()
throws SQLException {
  
  setup();
  CallableStatement cs = prepareCall("CALL PROCEDURE_WITHOUT_RESULTSET(?, ?) ON TABLE EMP.PARTITIONTESTTABLE WHERE SECONDID=4 AND THIRDID='3'");
  cs.registerOutParameter(2, java.sql.Types.VARCHAR, 20);
  int number=2;
  String name="INOUTPARAMETER";
  cs.setInt(1, number);
  cs.setString(2, name);
 
  
  cs.execute();
  
  ResultSet rs=cs.getResultSet();
  if(rs!=null || cs.getMoreResults()) {
    fail("no dynamic result set for the procedure!");
  }
  
  ParameterMetaData pmd=cs.getParameterMetaData();  
  int numParameters=pmd.getParameterCount();
  assertTrue(" the number of parameter is 2", numParameters==2);
  try {
    cs.getInt(1);
    fail("the in parameteter cannot be read!");
  } catch (Exception e) {
    
  }
  Object parameter2=cs.getObject(2);    
  assertTrue("the second inout parameter is "+name+number, parameter2.equals(name+number));
    
  

}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:35,代码来源:ProcedureTest.java

示例9: testDataAwareProcedureWithoutResultSetsUsingGlobalIndex

import java.sql.ParameterMetaData; //导入方法依赖的package包/类
public void testDataAwareProcedureWithoutResultSetsUsingGlobalIndex()
throws SQLException {
  
  setup();
  CallableStatement cs = prepareCall("CALL PROCEDURE_WITHOUT_RESULTSET(?, ?) ON TABLE EMP.PARTITIONTESTTABLE1 WHERE SECONDID=4 AND THIRDID='3'");
  cs.registerOutParameter(2, java.sql.Types.VARCHAR, 20);
  int number=2;
  String name="INOUTPARAMETER";
  cs.setInt(1, number);
  cs.setString(2, name);
 
  
  cs.execute();
  
  ResultSet rs=cs.getResultSet();
  if(rs!=null || cs.getMoreResults()) {
    fail("no dynamic result set for the procedure!");
  }
  
  ParameterMetaData pmd=cs.getParameterMetaData();  
  int numParameters=pmd.getParameterCount();
  assertTrue(" the number of parameter is 2", numParameters==2);
  try {
    cs.getInt(1);
    fail("the in parameteter cannot be read!");
  } catch (Exception e) {
    
  }
  Object parameter2=cs.getObject(2);    
  assertTrue("the second inout parameter is "+name+number, parameter2.equals(name+number));
    
  

}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:35,代码来源:ProcedureTest.java

示例10: setProcedure

import java.sql.ParameterMetaData; //导入方法依赖的package包/类
/**
 * @param procedure The procedure to set.
 * @param columns columns
 * @exception  Exception  Description of Exception
 */
public void setProcedure(String procedure, ArrayList columns) throws Exception {
	if (isconfigured) { return; }

	if (poolConnectionHandler != null) {
		con = poolConnectionHandler.getConnection();

		if (!isConnected()) { throw new Exception(
				"JDBCLogger::setProcedure(), Given connection isnt connected to database !"); }
	}

	this.procedure = procedure;
	// prepare call
	CallableStatement cStmt = this.createCallableStatement(columns.size());

	JDBCLogColumn logcol;

	ParameterMetaData pmd;

	// 2.6.2005 jschmied
	// ParameterMetaData is supported on different levels by Oracle
	try {
		// J2SDK 1.4+; limited support by Oracle drivers 10.x and 9.x
		pmd = cStmt.getParameterMetaData();
		num = pmd.getParameterCount();
		if (num >= 1) {
			// oracle 10.1.0.4 has some stubs in ParameterMetaData, 
			// try if a function throws a UnsupportedFeature exception
			pmd.getParameterType(1);
			pmd.getParameterTypeName(1);
			pmd.isNullable(1);
		}
	} catch (Exception e) {
		pmd = null;
		num = columns.size();
	}

	logcols = new ArrayList(num);

	for (int i = 1; i <= num; i++) {
		logcol = new JDBCLogColumn();
		JDBCColumnStorage col = (JDBCColumnStorage) columns.get(i - 1);
		logcol.name = col.column.toUpperCase();
		if (pmd == null) {
			logcol.type = col.type;
			logcol.sqlType = col.sqlType;
			logcol.nullable = true; // assume true
		} else {
			logcol.type = pmd.getParameterTypeName(i);
			logcol.sqlType = pmd.getParameterType(i);
			logcol.nullable = (pmd.isNullable(i) == ParameterMetaData.parameterNullable);
		}
		logcol.isWritable = true;
		logcols.add(logcol);
	}

	cStmt.close();
	freeConnection();

	isconfigured = true;

}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:67,代码来源:JDBCLogger.java

示例11: setupCallableStatementParams

import java.sql.ParameterMetaData; //导入方法依赖的package包/类
private void setupCallableStatementParams(CallableStatement cs) throws SQLException
{
	ParameterMetaData pmeta = getParameterMetaData();
	int numElems = pmeta.getParameterCount();

	for ( int i = 0; i < numElems; i ++)
	{
		boolean outputFlag = false;
		
		int parameterMode = pmeta.getParameterMode(i + 1);
		int parameterType = pmeta.getParameterType(i + 1);
                       int parameterPrecision = pmeta.getPrecision(i + 1);
                       int parameterScale = pmeta.getScale(i + 1);

		switch (parameterMode) {
			case JDBC30Translation.PARAMETER_MODE_IN:
				break;
			case JDBC30Translation.PARAMETER_MODE_OUT:
			case JDBC30Translation.PARAMETER_MODE_IN_OUT:
				outputFlag = true;
				break;
			case JDBC30Translation.PARAMETER_MODE_UNKNOWN:
				// It's only unknown if array
				String objectType = pmeta.getParameterClassName(i+1);
				parameterType =
					getOutputParameterTypeFromClassName(objectType);
				if (parameterType  != NOT_OUTPUT_PARAM)
					outputFlag = true;
		}

		if (outputFlag)
		{
			if (outputTypes == null) //not initialized yet, since previously none output
			{
				outputTypes = new int[numElems];
				outputPrecision = new int [numElems];
				outputScale = new int [numElems];
				for (int j = 0; j < numElems; j++) {
					outputTypes[j] = NOT_OUTPUT_PARAM;  //default init value
					outputPrecision[j] = NOT_OUTPUT_PARAM;
					outputScale[j] = NOT_OUTPUT_PARAM;
				}
			}
			// save the output type so we can register when we parse
			// the SQLDTA
			outputTypes[i] = parameterType;
			outputPrecision[i] = parameterPrecision;
			outputScale[i] = parameterScale;                
		}
		
	}
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:53,代码来源:DRDAStatement.java


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