當前位置: 首頁>>代碼示例>>Java>>正文


Java ResultSetMetaData.columnNullable方法代碼示例

本文整理匯總了Java中java.sql.ResultSetMetaData.columnNullable方法的典型用法代碼示例。如果您正苦於以下問題:Java ResultSetMetaData.columnNullable方法的具體用法?Java ResultSetMetaData.columnNullable怎麽用?Java ResultSetMetaData.columnNullable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.sql.ResultSetMetaData的用法示例。


在下文中一共展示了ResultSetMetaData.columnNullable方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validSetNullableValues

import java.sql.ResultSetMetaData; //導入方法依賴的package包/類
@DataProvider(name = "validSetNullableValues")
private Object[][] validSetNullableValues() {
    return new Object[][]{
        {ResultSetMetaData.columnNoNulls},
        {ResultSetMetaData.columnNullable},
        {ResultSetMetaData.columnNullableUnknown}
    };
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:9,代碼來源:RowSetMetaDataTests.java

示例2: updateColumnMetaData

import java.sql.ResultSetMetaData; //導入方法依賴的package包/類
public void updateColumnMetaData(String catalogName, String schemaName,
                                 String tableName, BatchSchema schema,
                                 List<Class<?>> getObjectClasses ) {
  final List<ColumnMetaData> newColumns =
      new ArrayList<ColumnMetaData>(schema.getFieldCount());
  for (int colOffset = 0; colOffset < schema.getFieldCount(); colOffset++) {
    final MaterializedField field = schema.getColumn(colOffset);
    Class<?> objectClass = getObjectClasses.get( colOffset );

    final String columnName = field.getPath().getRootSegment().getPath();

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

    final int nullability;
    switch ( field.getDataMode() ) {
      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 '"
                                  + field.getDataMode().name() + "'" );
    }
    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 =
        rpcDataType.hasPrecision() ? rpcDataType.getPrecision() : 0;
    final int scale = rpcDataType.hasScale() ? rpcDataType.getScale() : 0;
    final int displaySize = 10;

    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;
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:65,代碼來源:DrillColumnMetaDataList.java

示例3: setTable

import java.sql.ResultSetMetaData; //導入方法依賴的package包/類
/**
 * Configures this class, by reading in the structure of the log-table
 * Throws an exception, if an database-error occurs !
 * 
 * @param _table
 *            Description of Parameter
 * @exception Exception
 *                Description of Exception
 */
public void setTable(String _table) throws Exception {
	if (isconfigured) { return; }

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

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

	//Fill logcols with META-informations of the table-columns
	stmt = this.createUpdatableStatement();

	rs = stmt.executeQuery("SELECT " + _table + ".* FROM " + _table + " WHERE 1 = 2");

	JDBCLogColumn logcol;

	ResultSetMetaData rsmd = rs.getMetaData();

	num = rsmd.getColumnCount();

	logcols = new ArrayList(num);

	for (int i = 1; i <= num; i++) {
		logcol = new JDBCLogColumn();
		logcol.name = rsmd.getColumnName(i).toUpperCase();
		logcol.sqlType = rsmd.getColumnType(i);
		logcol.type = rsmd.getColumnTypeName(i);
		logcol.nullable = (rsmd.isNullable(i) == ResultSetMetaData.columnNullable);
		logcol.isWritable = rsmd.isWritable(i);
		if (!logcol.isWritable) {
			logcol.ignore = true;
		}
		logcols.add(logcol);
	}

	table = _table;

	rs.close();
	stmt.close();
	freeConnection();

	isconfigured = true;
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:54,代碼來源:JDBCLogger.java

示例4: updateColumnMetaData

import java.sql.ResultSetMetaData; //導入方法依賴的package包/類
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;
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:64,代碼來源:DremioColumnMetaDataList.java


注:本文中的java.sql.ResultSetMetaData.columnNullable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。