本文整理匯總了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);
}
}
}
}
示例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;
}
示例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());
}
示例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;
}
}
示例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 "";
}
示例6: intForColumnNullable
import java.sql.DatabaseMetaData; //導入方法依賴的package包/類
private static int intForColumnNullable(boolean nullable) {
return nullable ? DatabaseMetaData.columnNullable : DatabaseMetaData.columnNoNulls;
}