下面列出了java.sql.ResultSet#getNString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Test(expected = SQLFeatureNotSupportedException.class)
public void getNStringForColumnIndex() throws SQLException {
for (ResultSet each : resultSets) {
each.getNString(1);
}
}
@Test(expected = SQLFeatureNotSupportedException.class)
public void getNStringForColumnLabel() throws SQLException {
for (ResultSet each : resultSets) {
each.getNString("label");
}
}
private static Object getDataByType(int index, int columnType, ResultSet resultSet) throws SQLException {
if (columnType == Types.BIT) {
return resultSet.getByte(index);
}
if (columnType == Types.TINYINT) {
return resultSet.getByte(index);
}
if (columnType == Types.SMALLINT) {
return resultSet.getShort(index);
}
if (columnType == Types.INTEGER) {
return resultSet.getInt(index);
}
if (columnType == Types.BIGINT) {
return resultSet.getLong(index);
}
if (columnType == Types.FLOAT) {
return resultSet.getFloat(index);
}
if (columnType == Types.DOUBLE) {
return resultSet.getDouble(index);
}
if (columnType == Types.NUMERIC) {
return resultSet.getInt(index);
}
if (columnType == Types.DECIMAL) {
return resultSet.getBigDecimal(index);
}
if (columnType == Types.CHAR) {
return resultSet.getString(index);
}
if (columnType == Types.VARCHAR) {
return resultSet.getString(index);
}
if (columnType == Types.LONGNVARCHAR) {
return resultSet.getString(index);
}
if (columnType == Types.DATE) {
return resultSet.getDate(index);
}
if (columnType == Types.TIME) {
return resultSet.getTime(index);
}
if (columnType == Types.NCHAR) {
return resultSet.getNString(index);
}
if (columnType == Types.NVARCHAR) {
return resultSet.getNString(index);
}
if (columnType == Types.OTHER) {
return resultSet.getObject(index);
}
if (columnType == Types.BLOB) {
return resultSet.getBlob(index);
}
if (columnType == Types.BOOLEAN) {
return resultSet.getBoolean(index);
}
if (columnType == Types.ARRAY) {
return resultSet.getArray(index);
}
if (columnType == Types.TIMESTAMP) {
return resultSet.getTimestamp(index);
}
return resultSet.getObject(index);
}
public String getNString(ResultSet r) throws SQLException {
return r.getNString(ordinal);
}
public String getNString(ResultSet r) throws SQLException {
return r.getNString(label);
}
@Override
public String fromResult(ResultSet results, int column) throws SQLException {
return results.getNString(column);
}
public String get(final ResultSet target) throws SQLException {
return target.getNString(column);
}
@Override
public String getNullableResult(ResultSet rs, int index)
throws SQLException {
return rs.getNString(index);
}