本文整理了Java中java.sql.Clob.getSubString()
方法的一些代码示例,展示了Clob.getSubString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Clob.getSubString()
方法的具体详情如下:
包路径:java.sql.Clob
类名称:Clob
方法名:getSubString
[英]Gets a copy of a specified substring in this Clob.
[中]获取此Clob中指定子字符串的副本。
代码示例来源:origin: spring-projects/spring-framework
@Override
@Nullable
public String getClobAsString(ResultSet rs, int columnIndex) throws SQLException {
logger.debug("Returning CLOB as string");
if (this.wrapAsLob) {
Clob clob = rs.getClob(columnIndex);
return clob.getSubString(1, (int) clob.length());
}
else {
return rs.getString(columnIndex);
}
}
代码示例来源:origin: alibaba/druid
public String getClobAsString(ResultSet rs, int columnIndex) throws SQLException {
Clob clob = rs.getClob(columnIndex);
if (clob == null) {
return null;
}
return clob.getSubString(1, (int) clob.length());
}
代码示例来源:origin: apache/incubator-gobblin
private String readClobAsString(Clob logClob) throws SQLException {
if (logClob == null) {
return StringUtils.EMPTY;
}
long length = logClob.length();
return logClob.getSubString(1, (int) length);
}
代码示例来源:origin: org.postgresql/postgresql
private static String asString(final Clob in) throws SQLException {
return in.getSubString(1, (int) in.length());
}
代码示例来源:origin: spring-projects/spring-data-examples
@Nullable
@Override
public String convert(Clob clob) {
try {
return Math.toIntExact(clob.length()) == 0 //
? "" //
: clob.getSubString(1, Math.toIntExact(clob.length()));
} catch (SQLException e) {
throw new IllegalStateException("Failed to convert CLOB to String.", e);
}
}
}));
代码示例来源:origin: apache/hive
static String extractSqlClob(Object value) {
if (value == null) return null;
try {
if (value instanceof Clob) {
// we trim the Clob value to a max length an int can hold
int maxLength = (((Clob)value).length() < Integer.MAX_VALUE - 2) ? (int)((Clob)value).length() : Integer.MAX_VALUE - 2;
return ((Clob)value).getSubString(1L, maxLength);
} else {
return value.toString();
}
} catch (SQLException sqle) {
return null;
}
}
代码示例来源:origin: spring-projects/spring-data-examples
ModelMapEntry(String name, Clob description) {
key = name;
value = new Model();
value.name = name;
try {
value.description = description.getSubString(1, (int) description.length());
} catch (SQLException se) {
throw new RuntimeException(se);
}
}
代码示例来源:origin: spring-projects/spring-framework
obj = clob.getSubString(1, (int) clob.length());
代码示例来源:origin: speedment/speedment
@Override
public long position(final Clob clob, final long start) throws SQLException {
requireNonNull(clob);
assertNotFreeNotCalled();
return position(clob.getSubString(1, (int) clob.length()), start);
}
代码示例来源:origin: com.h2database/h2
/**
* Returns the value as a String.
*
* @param columnIndex (1,2,...)
* @return the value
*/
@Override
public String getString(int columnIndex) throws SQLException {
Object o = get(columnIndex);
if (o == null) {
return null;
}
switch (columns.get(columnIndex - 1).sqlType) {
case Types.CLOB:
Clob c = (Clob) o;
return c.getSubString(1, MathUtils.convertLongToInt(c.length()));
}
return o.toString();
}
代码示例来源:origin: alibaba/druid
@Override
public String clob_getSubString(ClobProxy clob, long pos, int length) throws SQLException {
if (this.pos < filterSize) {
return nextFilter().clob_getSubString(this, clob, pos, length);
}
return clob.getRawClob().getSubString(pos, length);
}
代码示例来源:origin: speedment/speedment
@Override
public String toJavaType(Column column, Class<?> entityType, Clob value) {
if (value == null) {
return null;
} else try {
if (value.length() < Integer.MAX_VALUE) {
return value.getSubString(1, (int) value.length());
} else {
throw new SpeedmentTypeMapperException(
"The provided Clob contains too many characters >" + Integer.MAX_VALUE
);
}
} catch (final SQLException sqle) {
throw new SpeedmentTypeMapperException("Unable to convert Clob to String.", sqle);
}
}
代码示例来源:origin: lealone/Lealone
/**
* Returns the value as a String.
*
* @param columnIndex (1,2,...)
* @return the value
*/
@Override
public String getString(int columnIndex) throws SQLException {
Object o = get(columnIndex);
if (o == null) {
return null;
}
switch (columns.get(columnIndex - 1).sqlType) {
case Types.CLOB:
Clob c = (Clob) o;
return c.getSubString(1, MathUtils.convertLongToInt(c.length()));
}
return o.toString();
}
代码示例来源:origin: hibernate/hibernate-orm
protected final String extractString(Clob clob) throws SQLException {
if ( StringClobImpl.class.isInstance( clob ) ) {
return ( (StringClobImpl) clob ).getValue();
}
return clob.getSubString( 1, (int)clob.length() );
}
代码示例来源:origin: redisson/redisson
throw new TypeConversionException("Clob is too big.");
return clob.getSubString(1, (int) length);
} catch (SQLException sex) {
throw new TypeConversionException(value, sex);
代码示例来源:origin: killbill/killbill
row.put(k, clob.getSubString(1, (int) clob.length()));
代码示例来源:origin: hibernate/hibernate-orm
try {
assertThat( clobField.getSubString( 1, (int) clobField.length() ), is( value3 ) );
代码示例来源:origin: hibernate/hibernate-orm
b.getClob().getSubString(2, 3);
b.setBlob(null);
b.getClob().getSubString(1, 6);
s.beginTransaction();
b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) );
assertTrue( b.getClob().getSubString(1, 7).equals("xcvfxvc") );
代码示例来源:origin: hibernate/hibernate-orm
b.getClob().getSubString(2, 3);
b.setBlob(null);
b.getClob().getSubString(1, 6);
s.beginTransaction();
b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) );
assertTrue( b.getClob().getSubString(1, 7).equals("xcvfxvc") );
代码示例来源:origin: oblac/jodd
@Test
void testStringConverter() throws SQLException {
StringConverter stringConverter = new StringConverter();
assertNull(stringConverter.convert(null));
assertEquals("123", stringConverter.convert("123"));
assertEquals("65,66", stringConverter.convert(arrb(65, 66)));
assertEquals("Ab", stringConverter.convert(arrc('A', 'b')));
assertEquals("One,two", stringConverter.convert(arrs("One", "two")));
assertEquals("123", stringConverter.convert(123));
assertEquals("java.lang.String", stringConverter.convert(String.class));
assertEquals("123,456", stringConverter.convert(arri(123,456)));
assertEquals("123,456", stringConverter.convert(arrl(123L,456L)));
assertEquals("777777.6,-32321.7", stringConverter.convert(arrf(777777.6f, -32321.7F)));
assertEquals("777777.6676732,-32321.700985", stringConverter.convert(arrd(777777.6676732D, -32321.700985D)));
assertEquals("12,-66", stringConverter.convert(arrs(12,-66)));
assertEquals("true,false,true", stringConverter.convert(arrl(true,false,true)));
{
// Clob via Mock
final Clob mock = Mockito.mock(Clob.class);
Mockito.when(mock.length()).thenReturn(123456789L);
Mockito.when(mock.getSubString(Mockito.eq(1L), Mockito.eq(123456789))).thenReturn("Hello there :-)");
assertEquals("Hello there :-)", stringConverter.convert(mock));
}
}
}
内容来源于网络,如有侵权,请联系作者删除!