use of javax.sql.rowset.serial.SerialException in project jdk8u_jdk by JetBrains.
the class SerialExceptionTests method test04.
/*
* Validate that the ordering of the returned Exceptions is correct using
* traditional while loop
*/
@Test
public void test04() {
SQLException ex = new SerialException("Exception 1");
ex.initCause(t1);
SerialException ex1 = new SerialException("Exception 2");
SerialException ex2 = new SerialException("Exception 3");
ex2.initCause(t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
while (ex != null) {
assertTrue(msgs[num++].equals(ex.getMessage()));
Throwable c = ex.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
ex = ex.getNextException();
}
}
use of javax.sql.rowset.serial.SerialException in project jdk8u_jdk by JetBrains.
the class SerialExceptionTests method test01.
/*
* Create SerialException with no-arg constructor
*/
@Test
public void test01() {
SerialException ex = new SerialException();
assertTrue(ex.getMessage() == null && ex.getSQLState() == null && ex.getCause() == null && ex.getErrorCode() == 0);
}
use of javax.sql.rowset.serial.SerialException in project sql-boot by sql-boot.
the class JdbcSqlQuery method getMapStream.
private Stream<Map<String, Object>> getMapStream(final String sqlText) {
logger.info(sqlText);
final SqlRowSet rowSet = new JdbcTemplate(dataSource).queryForRowSet(sqlText);
Iterator<Map<String, Object>> iterator = new Iterator<Map<String, Object>>() {
@Override
public boolean hasNext() {
return rowSet.next();
}
@Override
public Map<String, Object> next() {
return stream(rowSet.getMetaData().getColumnNames()).map(v -> {
Object object = rowSet.getObject(v);
if (object instanceof SerialClob) {
try {
return new SimpleEntry<>(v, (Object) ((SerialClob) object).getSubString(1, (int) ((SerialClob) object).length()));
} catch (SerialException e) {
e.printStackTrace();
}
}
return new SimpleEntry<>(v, object);
}).collect(toMap(k -> k.getKey(), /*.toLowerCase()*/
v -> ofNullable(v.getValue()).orElse(nullAlias), (a, b) -> a, LinkedHashMap::new));
}
};
return stream(spliteratorUnknownSize(iterator, ORDERED), false);
}
Aggregations