Example usage for java.sql ResultSet isWrapperFor

List of usage examples for java.sql ResultSet isWrapperFor

Introduction

In this page you can find the example usage for java.sql ResultSet isWrapperFor.

Prototype

boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException;

Source Link

Document

Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does.

Usage

From source file:com.github.woonsan.jdbc.jcr.impl.JcrJdbcResultSetTest.java

@Test
public void testWrapper() throws Exception {
    Statement statement = getConnection().createStatement();
    ResultSet rs = statement.executeQuery(SQL_EMPS);

    assertTrue(rs.isWrapperFor(JcrResultSet.class));

    try {/*  www .j a v a2 s .c  o m*/
        rs.isWrapperFor(null);
        fail();
    } catch (IllegalArgumentException ignore) {
    }

    assertFalse(rs.isWrapperFor(QueryResult.class));

    JcrResultSet jrs = rs.unwrap(JcrResultSet.class);
    assertNotNull(jrs);

    int count = 0;

    while (jrs.next()) {
        ++count;

        Node node = jrs.getCurrentRow().getNode();

        String nodeName = node.getName();
        String nodePath = node.getPath();
        String nodeId = node.getIdentifier();
        double score = jrs.getCurrentRow().getScore();

        assertEquals("testdata-" + count, nodeName);
        assertEquals("/testdatafolder/" + nodeName, nodePath);
        assertTrue(nodeId != null && !nodeId.isEmpty());
        assertTrue(score > 0.0);

    }

    rs.close();
    statement.close();
}