java.sql.ResultSetMetaData#columnNoNulls ( )源码实例Demo

下面列出了java.sql.ResultSetMetaData#columnNoNulls ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

protected DataTypeDescriptor resultColumnSQLType(ResultSetMetaData metaData, int i)
        throws SQLException {
    TypeId typeId = TypeId.getBuiltInTypeId(metaData.getColumnType(i));
    if (typeId == null) {
        try {
            typeId = TypeId.getUserDefinedTypeId(metaData.getColumnTypeName(i),
                                                 false);
        }
        catch (StandardException ex) {
            throw new SQLParserInternalException(ex);
        }
    }
    if (typeId.isDecimalTypeId()) {
        return new DataTypeDescriptor(typeId,
                                      metaData.getPrecision(i),
                                      metaData.getScale(i),
                                      metaData.isNullable(i) != ResultSetMetaData.columnNoNulls,
                                      metaData.getColumnDisplaySize(i));
        }
    else {
        return new DataTypeDescriptor(typeId,
                                      metaData.isNullable(i) != ResultSetMetaData.columnNoNulls,
                                      metaData.getColumnDisplaySize(i));
    }
}
 
源代码2 项目: GeoTriples   文件: Inspector.java
public List<ColumnDef> describeSelectStatement(String sqlQuery) {
	List<ColumnDef> result = new ArrayList<ColumnDef>();
	try {
		PreparedStatement stmt = connection.prepareStatement(sqlQuery);
		try {
			ResultSetMetaData meta = stmt.getMetaData();
			for (int i = 1; i <= meta.getColumnCount(); i++) {
				String name = meta.getColumnLabel(i);
				int type = meta.getColumnType(i);
				String typeName = meta.getColumnTypeName(i);
				int size = meta.getPrecision(i);
				DataType dataType = vendor.getDataType(type, typeName, size);
				if (dataType == null) {
					log.warn("Unknown datatype '" + 
							(size == 0 ? typeName : (typeName + "(" + size + ")")) + 
							"' (" + type + ")");
				}
				boolean isNullable = meta.isNullable(i) != ResultSetMetaData.columnNoNulls;
				result.add(new ColumnDef(
						Identifier.createDelimited(name), dataType, isNullable));
			}
			return result;
		} finally {
			stmt.close();
		}
	} catch (SQLException ex) {
		throw new D2RQException(ex, D2RQException.D2RQ_SQLEXCEPTION);
	}
}
 
源代码3 项目: dragonwell8_jdk   文件: RowSetMetaDataTests.java
@DataProvider(name = "validSetNullableValues")
private Object[][] validSetNullableValues() {
    return new Object[][]{
        {ResultSetMetaData.columnNoNulls},
        {ResultSetMetaData.columnNullable},
        {ResultSetMetaData.columnNullableUnknown}
    };
}
 
源代码4 项目: jTDS   文件: TdsCore.java
/**
 * Process TDS 5 Sybase 12+ Dynamic results parameter descriptor.
 * <p>When returning output parameters this token will be followed
 * by a TDS5_PARAMS_TOKEN with the actual data.
 * @throws IOException
 * @throws ProtocolException
 */
private void tds5ParamFmt2Token() throws IOException, ProtocolException {
    in.readInt(); // Packet length
    int paramCnt = in.readShort();
    ColInfo[] params = new ColInfo[paramCnt];
    for (int i = 0; i < paramCnt; i++) {
        //
        // Get the parameter details using the
        // ColInfo class as the server format is the same.
        //
        ColInfo col = new ColInfo();
        int colNameLen = in.read();
        col.realName = in.readNonUnicodeString(colNameLen);
        int column_flags = in.readInt();   /*  Flags */
        col.isCaseSensitive = false;
        col.nullable    = ((column_flags & 0x20) != 0)?
                                    ResultSetMetaData.columnNullable:
                                    ResultSetMetaData.columnNoNulls;
        col.isWriteable = (column_flags & 0x10) != 0;
        col.isIdentity  = (column_flags & 0x40) != 0;
        col.isKey       = (column_flags & 0x02) != 0;
        col.isHidden    = (column_flags & 0x01) != 0;

        col.userType    = in.readInt();
        TdsData.readType(in, col);
        // Skip locale information
        in.skip(1);
        params[i] = col;
    }
    currentToken.dynamParamInfo = params;
    currentToken.dynamParamData = new Object[paramCnt];
}
 
源代码5 项目: jdk8u60   文件: RowSetMetaDataTests.java
@DataProvider(name = "validSetNullableValues")
private Object[][] validSetNullableValues() {
    return new Object[][]{
        {ResultSetMetaData.columnNoNulls},
        {ResultSetMetaData.columnNullable},
        {ResultSetMetaData.columnNullableUnknown}
    };
}
 
源代码6 项目: gemfirexd-oss   文件: WiscMetaData.java
public int isNullable(int column) throws SQLException {
	if (column < 1 || column > 16) {
		throw new SQLException(
				"isNullable: column number " + column + " out of range.");
	}

	return ResultSetMetaData.columnNoNulls;
}
 
源代码7 项目: openjdk-jdk9   文件: RowSetMetaDataTests.java
@DataProvider(name = "validSetNullableValues")
private Object[][] validSetNullableValues() {
    return new Object[][]{
        {ResultSetMetaData.columnNoNulls},
        {ResultSetMetaData.columnNullable},
        {ResultSetMetaData.columnNullableUnknown}
    };
}
 
源代码8 项目: jdk8u-jdk   文件: RowSetMetaDataTests.java
@DataProvider(name = "validSetNullableValues")
private Object[][] validSetNullableValues() {
    return new Object[][]{
        {ResultSetMetaData.columnNoNulls},
        {ResultSetMetaData.columnNullable},
        {ResultSetMetaData.columnNullableUnknown}
    };
}
 
源代码9 项目: hottub   文件: RowSetMetaDataTests.java
@DataProvider(name = "validSetNullableValues")
private Object[][] validSetNullableValues() {
    return new Object[][]{
        {ResultSetMetaData.columnNoNulls},
        {ResultSetMetaData.columnNullable},
        {ResultSetMetaData.columnNullableUnknown}
    };
}
 
源代码10 项目: jTDS   文件: TdsCore.java
/**
 * Process TDS 5 Dynamic results parameter descriptors.
 * <p>
 * With Sybase 12+ this has been superseded by the TDS5_PARAMFMT2_TOKEN
 * except when used to return extended error information.
 *
 * @throws IOException
 * @throws ProtocolException
 */
private void tds5ParamFmtToken() throws IOException, ProtocolException {
    in.readShort(); // Packet length
    int paramCnt = in.readShort();
    ColInfo[] params = new ColInfo[paramCnt];
    for (int i = 0; i < paramCnt; i++) {
        //
        // Get the parameter details using the
        // ColInfo class as the server format is the same.
        //
        ColInfo col = new ColInfo();
        int colNameLen = in.read();
        col.realName = in.readNonUnicodeString(colNameLen);
        int column_flags = in.read();   /*  Flags */
        col.isCaseSensitive = false;
        col.nullable    = ((column_flags & 0x20) != 0)?
                                    ResultSetMetaData.columnNullable:
                                    ResultSetMetaData.columnNoNulls;
        col.isWriteable = (column_flags & 0x10) != 0;
        col.isIdentity  = (column_flags & 0x40) != 0;
        col.isKey       = (column_flags & 0x02) != 0;
        col.isHidden    = (column_flags & 0x01) != 0;

        col.userType    = in.readInt();
        if ((byte)in.peek() == TDS_DONE_TOKEN) {
            // Sybase 11.92 bug data type missing!
            currentToken.dynamParamInfo = null;
            currentToken.dynamParamData = null;
            // error trapped in sybasePrepare();
            messages.addDiagnostic(9999, 0, 16,
                                    "Prepare failed", "", "", 0);

            return; // Give up
        }
        TdsData.readType(in, col);
        // Skip locale information
        in.skip(1);
        params[i] = col;
    }
    currentToken.dynamParamInfo = params;
    currentToken.dynamParamData = new Object[paramCnt];
}
 
@Override
public int isNullable(int index) throws SQLException {
    return (header.getByPosition(index - 1).type() instanceof DataTypeNullable) ?
        ResultSetMetaData.columnNullable : ResultSetMetaData.columnNoNulls;
}
 
private Builder withNotNull() {
  this.nulls = ResultSetMetaData.columnNoNulls;
  return this;
}
 
源代码13 项目: dremio-oss   文件: DremioColumnMetaDataList.java
public void updateColumnMetaData(String catalogName, String schemaName,
                                 String tableName, BatchSchema schema,
                                 List<Class<?>> getObjectClasses ) {
  final List<ColumnMetaData> newColumns =
      new ArrayList<>(schema.getFieldCount());
  for (int colOffset = 0; colOffset < schema.getFieldCount(); colOffset++) {
    final Field field = schema.getColumn(colOffset);
    Class<?> objectClass = getObjectClasses.get( colOffset );

    final String columnName = field.getName();

    final MajorType rpcDataType = getMajorTypeForField(field);
    final AvaticaType bundledSqlDataType = getAvaticaType(rpcDataType);
    final String columnClassName = objectClass.getName();

    final int nullability;
    switch ( rpcDataType.getMode() ) {
      case OPTIONAL: nullability = ResultSetMetaData.columnNullable; break;
      case REQUIRED: nullability = ResultSetMetaData.columnNoNulls;  break;
      // Should REPEATED still map to columnNoNulls? or to columnNullable?
      case REPEATED: nullability = ResultSetMetaData.columnNoNulls;  break;
      default:
        throw new AssertionError( "Unexpected new DataMode value '"
                                  + rpcDataType.getMode() + "'" );
    }
    final boolean isSigned = Types.isJdbcSignedType( rpcDataType );

    // TODO(DRILL-3355):  TODO(DRILL-3356):  When string lengths, precisions,
    // interval kinds, etc., are available from RPC-level data, implement:
    // - precision for ResultSetMetadata.getPrecision(...) (like
    //   getColumns()'s COLUMN_SIZE)
    // - scale for getScale(...), and
    // - and displaySize for getColumnDisplaySize(...).
    final int precision = Types.getPrecision(rpcDataType);
    final int scale = Types.getScale(rpcDataType);
    final int displaySize = Types.getJdbcDisplaySize(rpcDataType);

    ColumnMetaData col = new ColumnMetaData(
        colOffset,    // (zero-based ordinal (for Java arrays/lists).)
        false,        /* autoIncrement */
        false,        /* caseSensitive */
        true,         /* searchable */
        false,        /* currency */
        nullability,
        isSigned,
        displaySize,
        columnName,   /* label */
        columnName,   /* columnName */
        schemaName,
        precision,
        scale,
        tableName,
        catalogName,
        bundledSqlDataType,
        true,         /* readOnly */
        false,        /* writable */
        false,        /* definitelyWritable */
        columnClassName
       );
    newColumns.add(col);
  }
  columns = newColumns;
}
 
源代码14 项目: phoenix   文件: PhoenixResultSetMetaData.java
@Override
public int isNullable(int column) throws SQLException {
    return rowProjector.getColumnProjector(column-1).getExpression().isNullable() ? ResultSetMetaData.columnNullable : ResultSetMetaData.columnNoNulls;
}
 
源代码15 项目: jaybird   文件: FBResultSetMetaData.java
@Override
public int isNullable(int column) throws SQLException {
    return (getFieldDescriptor(column).getType() & 1) == 1
            ? ResultSetMetaData.columnNullable
            : ResultSetMetaData.columnNoNulls;
}
 
源代码16 项目: tddl   文件: MockResultSetMetaData.java
public int isNullable(int column) throws SQLException {
    return ResultSetMetaData.columnNoNulls;
}
 
源代码17 项目: phoenix   文件: PhoenixParameterMetaData.java
@Override
public int isNullable(int index) throws SQLException {
    return getParam(index).isNullable() ? ResultSetMetaData.columnNullable : ResultSetMetaData.columnNoNulls;
}
 
源代码18 项目: jTDS   文件: TdsCore.java
/**
* Process Sybase 12+ wide result token which provides enhanced
* column meta data.
*
* @throws IOException
*/
private void tds5WideResultToken()
    throws IOException, ProtocolException
{
    in.readInt(); // Packet length
    int colCnt   = in.readShort();
    columns = new ColInfo[colCnt];
    rowData = new Object[colCnt];
    tables  = null;

    for (int colNum = 0; colNum < colCnt; ++colNum) {
        ColInfo col = new ColInfo();
        //
        // Get the alias name
        //
        int nameLen = in.read();
        col.name  = in.readNonUnicodeString(nameLen);
        //
        // Get the catalog name
        //
        nameLen = in.read();
        col.catalog = in.readNonUnicodeString(nameLen);
        //
        // Get the schema name
        //
        nameLen = in.read();
        col.schema = in.readNonUnicodeString(nameLen);
        //
        // Get the table name
        //
        nameLen = in.read();
        col.tableName = in.readNonUnicodeString(nameLen);
        //
        // Get the column name
        //
        nameLen = in.read();
        col.realName  = in.readNonUnicodeString(nameLen);
        if (col.name == null || col.name.length() == 0) {
            col.name = col.realName;
        }
        int column_flags = in.readInt();   /*  Flags */
        col.isCaseSensitive = false;
        col.nullable    = ((column_flags & 0x20) != 0)?
                               ResultSetMetaData.columnNullable:
                                    ResultSetMetaData.columnNoNulls;
        col.isWriteable = (column_flags & 0x10) != 0;
        col.isIdentity  = (column_flags & 0x40) != 0;
        col.isKey       = (column_flags & 0x02) != 0;
        col.isHidden    = (column_flags & 0x01) != 0;

        col.userType    = in.readInt();
        TdsData.readType(in, col);
        // Skip locale information
        in.skip(1);
        columns[colNum] = col;
    }
    endOfResults = false;
}
 
源代码19 项目: jTDS   文件: TdsCore.java
/**
 * Process a TDS 4.2 column format token.
 *
 * @throws IOException
 * @throws ProtocolException
 */
private void tds4ColFormatToken()
    throws IOException, ProtocolException {

    final int pktLen = in.readShort();

    int bytesRead = 0;
    int numColumns = 0;
    while (bytesRead < pktLen) {
        if (numColumns > columns.length) {
            throw new ProtocolException("Too many columns in TDS_COL_FMT packet");
        }
        ColInfo col = columns[numColumns];

        if (serverType == Driver.SQLSERVER) {
            col.userType = in.readShort();

            int flags = in.readShort();

            col.nullable = ((flags & 0x01) != 0)?
                                ResultSetMetaData.columnNullable:
                                   ResultSetMetaData.columnNoNulls;
            col.isCaseSensitive = (flags & 0x02) != 0;
            col.isWriteable = (flags & 0x0C) != 0;
            col.isIdentity = (flags & 0x10) != 0;
        } else {
            // Sybase does not send column flags
            col.isCaseSensitive = false;
            col.isWriteable = true;

            if (col.nullable == ResultSetMetaData.columnNoNulls) {
                col.nullable = ResultSetMetaData.columnNullableUnknown;
            }

            col.userType = in.readInt();
        }
        bytesRead += 4;

        bytesRead += TdsData.readType(in, col);

        numColumns++;
    }

    if (numColumns != columns.length) {
        throw new ProtocolException("Too few columns in TDS_COL_FMT packet");
    }

    endOfResults = false;
}
 
源代码20 项目: gemfirexd-oss   文件: DataTypeUtilities.java
/**
 * Is the data type nullable.
 * 
 * @param dtd
 *          data type descriptor
 */
public static int isNullable(DataTypeDescriptor dtd) {
  return dtd.isNullable() ? ResultSetMetaData.columnNullable
      : ResultSetMetaData.columnNoNulls;
}