本文整理了Java中java.sql.ResultSet.getBoolean
方法的一些代码示例,展示了ResultSet.getBoolean
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResultSet.getBoolean
方法的具体详情如下:
包路径:java.sql.ResultSet
类名称:ResultSet
方法名:getBoolean
[英]Gets the value of a column specified by column index as a boolean.
[中]获取列索引指定为布尔值的列的值。
代码示例来源:origin: nutzam/nutz
public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
if (null != rs && rs.next())
return rs.getBoolean(1);
return null;
}
代码示例来源:origin: spring-projects/spring-security
@Override
public UserDetails mapRow(ResultSet rs, int rowNum)
throws SQLException {
String username = rs.getString(1);
String password = rs.getString(2);
boolean enabled = rs.getBoolean(3);
return new User(username, password, enabled, true, true, true,
AuthorityUtils.NO_AUTHORITIES);
}
代码示例来源:origin: looly/hutool
/**
* 初始化
*
* @param tableName 表名
* @param columnMetaRs 列的meta ResultSet
* @throws SQLException SQL执行异常
*/
public void init(String tableName, ResultSet columnMetaRs) throws SQLException {
this.tableName = tableName;
this.name = columnMetaRs.getString("COLUMN_NAME");
this.type = columnMetaRs.getInt("DATA_TYPE");
this.size = columnMetaRs.getInt("COLUMN_SIZE");
this.isNullable = columnMetaRs.getBoolean("NULLABLE");
this.comment = columnMetaRs.getString("REMARKS");
}
代码示例来源:origin: gocd/gocd
static Migration convertPipelineSelectionsToFilters() {
return (cxn) -> {
if (!required(cxn)) return;
try (Statement s = cxn.createStatement()) {
final ResultSet rs = s.executeQuery("SELECT id, selections, isblacklist FROM pipelineselections WHERE version = 0");
while (rs.next()) {
perform(cxn, rs.getLong(ID), rs.getString(SELECTIONS), rs.getBoolean(BLACKLIST));
}
}
};
}
代码示例来源:origin: com.h2database/h2
private String getDefaultSchemaName(DatabaseMetaData meta) {
String defaultSchemaName = "";
try {
if (isOracle) {
return meta.getUserName();
} else if (isPostgreSQL) {
return "public";
} else if (isMySQL) {
return "";
} else if (isDerby) {
return StringUtils.toUpperEnglish(meta.getUserName());
} else if (isFirebird) {
return null;
}
ResultSet rs = meta.getSchemas();
int index = rs.findColumn("IS_DEFAULT");
while (rs.next()) {
if (rs.getBoolean(index)) {
defaultSchemaName = rs.getString("TABLE_SCHEM");
}
}
} catch (SQLException e) {
// IS_DEFAULT not found
}
return defaultSchemaName;
}
代码示例来源:origin: killbill/killbill
@Override
public DefaultColumnInfo map(final int index, final ResultSet r, final StatementContext ctx) throws SQLException {
final String tableName = r.getString("table_name");
final String columnName = r.getString("column_name");
final Long scale = r.getLong("numeric_scale");
final Long precision = r.getLong("numeric_precision");
// Special handling for PostgreSQL - the implementation of AbstractJdbc2ResultSet#getBoolean doesn't support YES/NO
final String isNullableString = r.getString("is_nullable");
final boolean isNullable;
if ("YES".equalsIgnoreCase(isNullableString)) {
isNullable = true;
} else if ("NO".equalsIgnoreCase(isNullableString)) {
isNullable = false;
} else {
isNullable = r.getBoolean("is_nullable");
}
final Long maximumLength = r.getLong("character_maximum_length");
final String dataType = r.getString("data_type");
return new DefaultColumnInfo(tableName, columnName, scale, precision, isNullable, maximumLength, dataType);
}
}
代码示例来源:origin: net.sf.opencsv/opencsv
break;
case Types.BOOLEAN:
boolean b = rs.getBoolean(colIndex);
value = Boolean.valueOf(b).toString();
break;
break;
case Types.TIMESTAMP:
value = handleTimestamp(rs.getTimestamp(colIndex));
break;
case NVARCHAR: // todo : use rs.getNString
case Types.VARCHAR:
case Types.CHAR:
value = rs.getString(colIndex);
break;
default:
代码示例来源:origin: azkaban/azkaban
@Override
public List<Executor> handle(final ResultSet rs) throws SQLException {
if (!rs.next()) {
return Collections.emptyList();
}
final List<Executor> executors = new ArrayList<>();
do {
final int id = rs.getInt(1);
final String host = rs.getString(2);
final int port = rs.getInt(3);
final boolean active = rs.getBoolean(4);
final Executor executor = new Executor(id, host, port, active);
executors.add(executor);
} while (rs.next());
return executors;
}
}
代码示例来源:origin: nutzam/nutz
public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
List<Boolean> list = new LinkedList<Boolean>();
if (null != rs && rs.next())
list.add(rs.getBoolean(1));
boolean[] array = new boolean[list.size()];
for (int i = 0; i < array.length; i++) {
array[i] = list.get(i);
}
return array;
}
代码示例来源:origin: apache/drill
@AfterClass
public static void tearDownConnection() throws SQLException {
final ResultSet util =
connection.createStatement().executeQuery( "DROP VIEW " + VIEW_NAME + "" );
assertTrue( util.next() );
assertTrue("Error dropping temporary test-columns view " + VIEW_NAME + ": "
+ util.getString( 2 ), util.getBoolean( 1 ) );
connection.close();
}
代码示例来源:origin: looly/hutool
/**
* 初始化
*
* @param tableName 表名
* @param columnMetaRs 列的meta ResultSet
* @throws SQLException SQL执行异常
*/
public void init(String tableName, ResultSet columnMetaRs) throws SQLException {
this.tableName = tableName;
this.name = columnMetaRs.getString("COLUMN_NAME");
this.type = columnMetaRs.getInt("DATA_TYPE");
this.size = columnMetaRs.getInt("COLUMN_SIZE");
this.isNullable = columnMetaRs.getBoolean("NULLABLE");
this.comment = columnMetaRs.getString("REMARKS");
}
代码示例来源:origin: org.springframework.security/spring-security-core
@Override
public UserDetails mapRow(ResultSet rs, int rowNum)
throws SQLException {
String username = rs.getString(1);
String password = rs.getString(2);
boolean enabled = rs.getBoolean(3);
return new User(username, password, enabled, true, true, true,
AuthorityUtils.NO_AUTHORITIES);
}
代码示例来源:origin: Netflix/conductor
protected <V> V getScalarFromResultSet(ResultSet rs, Class<V> returnType) throws SQLException {
Object value = null;
if (Integer.class == returnType) {
value = rs.getInt(1);
} else if (Long.class == returnType) {
value = rs.getLong(1);
} else if (String.class == returnType) {
value = rs.getString(1);
} else if (Boolean.class == returnType) {
value = rs.getBoolean(1);
} else if (Double.class == returnType) {
value = rs.getDouble(1);
} else if (Date.class == returnType) {
value = rs.getDate(1);
} else if (Timestamp.class == returnType) {
value = rs.getTimestamp(1);
} else {
value = rs.getObject(1);
}
if (null == value) {
throw new NullPointerException("Cannot get value from ResultSet of type " + returnType.getName());
}
return returnType.cast(value);
}
代码示例来源:origin: apache/ignite
@Override public Void call() throws Exception {
ResultSet rs0 = stmt.executeQuery("select 'qwe'");
assert rs0.next();
assert rs0.getBoolean(1);
return null;
}
}, SQLException.class, "Cannot convert to boolean: qwe");
代码示例来源:origin: apache/drill
@AfterClass
public static void tearDownConnection() throws SQLException {
final ResultSet util =
connection.createStatement().executeQuery( "DROP VIEW " + VIEW_NAME + "" );
assertTrue( util.next() );
assertTrue( "Error dropping temporary test-columns view " + VIEW_NAME + ": "
+ util.getString( 2 ), util.getBoolean( 1 ) );
connection.close();
}
代码示例来源:origin: speedment/speedment
static TypeInfoMetaData of(ResultSet rs) throws SQLException {
final String sqlTypeName = rs.getString("TYPE_NAME");
final int javaSqlTypeInt = rs.getInt("DATA_TYPE");
final int precision = rs.getInt("PRECISION");
final short nullable = rs.getShort("NULLABLE");
final boolean unsigned = rs.getBoolean("UNSIGNED_ATTRIBUTE");
return of(sqlTypeName, javaSqlTypeInt, precision, precision, nullable, unsigned);
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public ColumnIndex convert(ResultSet rs) throws SQLException {
return new ColumnIndex(rs.getString(1), rs.getBoolean(2), rs.getString(3));
}
}
代码示例来源:origin: alibaba/druid
while (rs.next()) {
out.print(rs.getString(columnIndex));
} else if (type == Types.DATE) {
Date date = rs.getDate(columnIndex);
boolean value = rs.getBoolean(columnIndex);
if (rs.wasNull()) {
out.print("null");
boolean value = rs.getBoolean(columnIndex);
if (rs.wasNull()) {
out.print("null");
int value = rs.getInt(columnIndex);
if (rs.wasNull()) {
out.print("null");
long value = rs.getLong(columnIndex);
if (rs.wasNull()) {
out.print("null");
Object object = rs.getString(columnIndex);
代码示例来源:origin: apache/ignite
@Override public Void call() throws Exception {
ResultSet rs0 = stmt.executeQuery("select ''");
assert rs0.next();
assert rs0.getBoolean(1);
return null;
}
}, SQLException.class, "Cannot convert to boolean: ");
代码示例来源:origin: apache/drill
@AfterClass
public static void tearDownConnection() throws SQLException {
ResultSet util =
connection.createStatement().executeQuery( "DROP VIEW " + VIEW_NAME + "" );
assertTrue( util.next() );
assertTrue( "Error dropping temporary test-columns view " + VIEW_NAME + ": "
+ util.getString( 2 ), util.getBoolean( 1 ) );
connection.close();
}
内容来源于网络,如有侵权,请联系作者删除!