Java Code Examples for java.sql.ResultSet#getNClob()

The following examples show how to use java.sql.ResultSet#getNClob() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataNTypeTest.java    From mariadb-connector-j with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testSetNClob() throws Exception {

  createTable("testSetNClob", "id int not null primary key, strm text", "CHARSET utf8");
  PreparedStatement stmt =
      sharedConnection.prepareStatement("insert into testSetNClob (id, strm) values (?,?)");
  NClob nclob = sharedConnection.createNClob();
  OutputStream stream = nclob.setAsciiStream(1);
  byte[] bytes = "hello".getBytes();
  stream.write(bytes);

  stmt.setInt(1, 1);
  stmt.setNClob(2, nclob);
  stmt.execute();

  ResultSet rs = sharedConnection.createStatement().executeQuery("select * from testSetNClob");
  assertTrue(rs.next());
  assertTrue(rs.getObject(2) instanceof String);
  assertTrue(rs.getString(2).equals("hello"));
  NClob resultNClob = rs.getNClob(2);
  assertNotNull(resultNClob);
  assertEquals(5, resultNClob.getAsciiStream().available());
}
 
Example 2
Source File: UnsupportedOperationResultSetTest.java    From sharding-jdbc-1.5.1 with Apache License 2.0 4 votes vote down vote up
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertGetNClobForColumnIndex() throws SQLException {
    for (ResultSet each : resultSets) {
        each.getNClob(1);
    }
}
 
Example 3
Source File: UnsupportedOperationResultSetTest.java    From sharding-jdbc-1.5.1 with Apache License 2.0 4 votes vote down vote up
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertGetNClobForColumnLabel() throws SQLException {
    for (ResultSet each : resultSets) {
        each.getNClob("label");
    }
}
 
Example 4
Source File: AvaticaResultSetConversionsTest.java    From calcite-avatica with Apache License 2.0 4 votes vote down vote up
public Object getNClob(ResultSet r) throws SQLException {
  return r.getNClob(ordinal);
}
 
Example 5
Source File: AvaticaResultSetConversionsTest.java    From calcite-avatica with Apache License 2.0 4 votes vote down vote up
public NClob getNClob(ResultSet r) throws SQLException {
  return r.getNClob(label);
}
 
Example 6
Source File: UnsupportedOperationResultSetTest.java    From shardingsphere with Apache License 2.0 4 votes vote down vote up
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertGetNClobForColumnIndex() throws SQLException {
    for (ResultSet each : resultSets) {
        each.getNClob(1);
    }
}
 
Example 7
Source File: UnsupportedOperationResultSetTest.java    From shardingsphere with Apache License 2.0 4 votes vote down vote up
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertGetNClobForColumnLabel() throws SQLException {
    for (ResultSet each : resultSets) {
        each.getNClob("label");
    }
}
 
Example 8
Source File: NClobResultSetGetter.java    From SimpleFlatMapper with MIT License 4 votes vote down vote up
public NClob get(final ResultSet target) throws SQLException {
	return target.getNClob(column);
}