本文整理汇总了Java中java.sql.ParameterMetaData.getParameterType方法的典型用法代码示例。如果您正苦于以下问题:Java ParameterMetaData.getParameterType方法的具体用法?Java ParameterMetaData.getParameterType怎么用?Java ParameterMetaData.getParameterType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.ParameterMetaData
的用法示例。
在下文中一共展示了ParameterMetaData.getParameterType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: writeSQLUDTGRP
import java.sql.ParameterMetaData; //导入方法依赖的package包/类
/**
* Write SQLUDTGRP (SQL Descriptor User-Defined Type Group Descriptor)
*
* This is the format from the DRDA spec, Volume 1, section 5.6.4.10.
* However, this format is not rich enough to carry the information needed
* by JDBC. This format does not have a subtype code for JAVA_OBJECT and
* this format does not convey the Java class name needed
* by ResultSetMetaData.getColumnClassName().
*
* SQLUDXTYPE; DRDA TYPE I4; ENVLID 0x02; Length Override 4
* Constants which map to java.sql.Types constants DISTINCT, STRUCT, and REF.
* But DRDA does not define a constant which maps to java.sql.Types.JAVA_OBJECT.
* SQLUDTRDB; DRDA TYPE VCS; ENVLID 0x32; Length Override 255
* Database name.
* SQLUDTSCHEMA_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 255
* SQLUDTSCHEMA_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 255
* Schema name. One of the above.
* SQLUDTNAME_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 255
* SQLUDTNAME_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 255
* Unqualified UDT name. One of the above.
*
* Instead, we use the following format and only for communication between
* Derby servers and Derby clients which are both at version 10.4 or higher.
* For all other client/server combinations, we send null.
*
* SQLUDTNAME_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 255
* SQLUDTNAME_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 255
* Fully qualified UDT name. One of the above.
* SQLUDTCLASSNAME_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override FdocaConstants.LONGVARCHAR_MAX_LEN
* SQLUDTCLASSNAME_s; DRDA TYPE VCS; ENVLID 0x32; Length Override FdocaConstants.LONGVARCHAR_MAX_LEN
* Name of the Java class bound to the UDT. One of the above.
*
* @param rsmeta resultset meta data
* @param pmeta parameter meta data
* @param elemNum column number we are returning (in case of result set), or,
* parameter number (in case of parameter)
* @param rtnOutput whether this is for a result set
*
* @throws DRDAProtocolException
* @throws SQLException
*/
private void writeSQLUDTGRP(ResultSetMetaData rsmeta,
ParameterMetaData pmeta,
int jdbcElemNum, boolean rtnOutput)
throws DRDAProtocolException,SQLException
{
int jdbcType = rtnOutput ?
rsmeta.getColumnType( jdbcElemNum) : pmeta.getParameterType( jdbcElemNum );
if ( !(jdbcType == Types.JAVA_OBJECT) || !appRequester.supportsUDTs() )
{
writer.writeByte(CodePoint.NULLDATA);
return;
}
String typeName = rtnOutput ?
rsmeta.getColumnTypeName( jdbcElemNum ) : pmeta.getParameterTypeName( jdbcElemNum );
String className = rtnOutput ?
rsmeta.getColumnClassName( jdbcElemNum ) : pmeta.getParameterClassName( jdbcElemNum );
writeVCMorVCS( typeName );
writeVCMorVCS( className );
}
示例3: 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;
}
}
}
示例4: getParameterType
import java.sql.ParameterMetaData; //导入方法依赖的package包/类
/**
* パラメータタイプを取得します。
* <pre>
* パラメータメタデータがサポートされていないOracle JDBCのドライバの場合組み直して使用します。
* </pre>
*
* @param meta ParameterMetaData。
* @param idx インデックス。
* @return パラメータタイプ。java.sql.Types.xxxの値。
* @throws Exception 例外。
*/
protected int getParameterType(final ParameterMetaData meta, final int idx) throws Exception {
return meta.getParameterType(idx);
}