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


Java DatabaseMetaData.columnNoNulls方法代碼示例

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


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

示例1: setFKColumnsNull

import java.sql.DatabaseMetaData; //導入方法依賴的package包/類
private static void setFKColumnsNull(Connection conn, String user,
        String tableName) throws SQLException {
    ResultSet rs = conn.getMetaData()
            .getExportedKeys(null, null, tableName);
    Statement stmt = conn.createStatement();
    while (rs.next()) {
        String sourceTableName = rs.getString("FKTABLE_NAME");
        String columnName = rs.getString("FKCOLUMN_NAME");
        ResultSet columns = conn.getMetaData().getColumns(null, user,
                sourceTableName, columnName);
        while (columns.next()) {
            if (columns.getInt("NULLABLE") != DatabaseMetaData.columnNoNulls) {
                String queryString = String.format(
                        "UPDATE %s SET %s = NULL", sourceTableName,
                        columnName);
                stmt.executeUpdate(queryString);
            }
        }
    }
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:21,代碼來源:TestDBSetup.java

示例2: getColumnNullability

import java.sql.DatabaseMetaData; //導入方法依賴的package包/類
protected static int getColumnNullability(Field field) {
  // Check annotations first
  if (field.isAnnotationPresent(ColumnNoNulls.class)) {
    return DatabaseMetaData.columnNoNulls;
  }

  if (field.isAnnotationPresent(ColumnNullable.class)) {
    return DatabaseMetaData.columnNullable;
  }

  if (field.isAnnotationPresent(ColumnNullableUnknown.class)) {
    return DatabaseMetaData.columnNullableUnknown;
  }

  // check the field type to decide if annotated, as a fallback
  if (field.getType().isPrimitive()) {
    return DatabaseMetaData.columnNoNulls;
  }

  return DatabaseMetaData.columnNullable;
}
 
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:22,代碼來源:MetaImpl.java

示例3: dummy

import java.sql.DatabaseMetaData; //導入方法依賴的package包/類
/** Creates a ColumnMetaData for result sets that are not based on a struct
 * but need to have a single 'field' for purposes of
 * {@link java.sql.ResultSetMetaData}. */
public static ColumnMetaData dummy(AvaticaType type, boolean nullable) {
  return new ColumnMetaData(
      0,
      false,
      true,
      false,
      false,
      nullable
          ? DatabaseMetaData.columnNullable
          : DatabaseMetaData.columnNoNulls,
      true,
      -1,
      null,
      null,
      null,
      -1,
      -1,
      null,
      null,
      type,
      true,
      false,
      false,
      type.columnClassName());
}
 
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:29,代碼來源:ColumnMetaData.java

示例4: getColumnNullable

import java.sql.DatabaseMetaData; //導入方法依賴的package包/類
public static Nullable getColumnNullable(int dbmdColumnNullable) {
    switch (dbmdColumnNullable) {
        case DatabaseMetaData.columnNoNulls:
            return Nullable.NOT_NULLABLE;
        case DatabaseMetaData.columnNullable:
            return Nullable.NULLABLE;
        case DatabaseMetaData.columnNullableUnknown:
        default:
            return Nullable.UNKNOWN;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:JDBCUtils.java

示例5: getNotNull

import java.sql.DatabaseMetaData; //導入方法依賴的package包/類
private String getNotNull(ResultSet columns) throws SQLException
{
	int nullable = columns.getInt("NULLABLE");
	if (nullable == DatabaseMetaData.columnNoNulls)
		return "NOT NULL";
	return "";
}
 
開發者ID:olavloite,項目名稱:spanner-jdbc-converter,代碼行數:8,代碼來源:TableConverter.java

示例6: intForColumnNullable

import java.sql.DatabaseMetaData; //導入方法依賴的package包/類
private static int intForColumnNullable(boolean nullable) {
  return nullable ? DatabaseMetaData.columnNullable : DatabaseMetaData.columnNoNulls;
}
 
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:4,代碼來源:MetaImpl.java


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