java.sql.ResultSet#getNClob ( )源码实例Demo

下面列出了java.sql.ResultSet#getNClob ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: mariadb-connector-j   文件: DataNTypeTest.java
@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());
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertGetNClobForColumnIndex() throws SQLException {
    for (ResultSet each : resultSets) {
        each.getNClob(1);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertGetNClobForColumnLabel() throws SQLException {
    for (ResultSet each : resultSets) {
        each.getNClob("label");
    }
}
 
public Object getNClob(ResultSet r) throws SQLException {
  return r.getNClob(ordinal);
}
 
public NClob getNClob(ResultSet r) throws SQLException {
  return r.getNClob(label);
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertGetNClobForColumnIndex() throws SQLException {
    for (ResultSet each : resultSets) {
        each.getNClob(1);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertGetNClobForColumnLabel() throws SQLException {
    for (ResultSet each : resultSets) {
        each.getNClob("label");
    }
}
 
源代码8 项目: SimpleFlatMapper   文件: NClobResultSetGetter.java
public NClob get(final ResultSet target) throws SQLException {
	return target.getNClob(column);
}