Package java.sql

Examples of java.sql.Connection.unwrap()


    Connection con = new TestConnectionImpl();
    Connection proxy = ProxyFactory.createProxy(con, new GenericInvocationHandler<Connection>(con));

    // if the underlying object extends the class (or matches the class) then the underlying object should be returned.
    {
      AbstractTestConnection unwrapped = proxy.unwrap(AbstractTestConnection.class);
      assertFalse(ProxyFactory.isProxy(unwrapped));
    }

    {
      TestConnectionImpl unwrapped = proxy.unwrap(TestConnectionImpl.class);
View Full Code Here


      AbstractTestConnection unwrapped = proxy.unwrap(AbstractTestConnection.class);
      assertFalse(ProxyFactory.isProxy(unwrapped));
    }

    {
      TestConnectionImpl unwrapped = proxy.unwrap(TestConnectionImpl.class);
      assertFalse(ProxyFactory.isProxy(unwrapped));
    }

  }
View Full Code Here

    Connection proxy = ProxyFactory.createProxy(underlying, new GenericInvocationHandler<Connection>(underlying));

    // TestConnection is an interface of the actual connection but not of the proxy.  Unwrapping works
    // but a proxy is not returned
    {
      TestConnection unwrapped = proxy.unwrap(TestConnection.class);
      assertFalse(ProxyFactory.isProxy(unwrapped));
    }

    // ResultSet is not implemented at all - an exception will be thrown
    try {
View Full Code Here

      assertFalse(ProxyFactory.isProxy(unwrapped));
    }

    // ResultSet is not implemented at all - an exception will be thrown
    try {
      proxy.unwrap(ResultSet.class);
      fail("Expected exception not thrown");
    } catch (SQLException e) {
    }

  }
View Full Code Here

  }

  @Before
  public void setUp() throws SQLException {
    Connection connection = DriverManager.getConnection("jdbc:optiq:");
    OptiqConnection optiqConnection = connection.unwrap(OptiqConnection.class);
    SchemaPlus rootSchema = optiqConnection.getRootSchema();
    rootSchema.add("test", new ReflectiveSchema(new TestSchema()));
    optiqConnection.setSchema("test");
    this.conn = optiqConnection;
  }
View Full Code Here

    try {
      Class.forName("net.hydromatic.optiq.jdbc.Driver");
      Connection connection =
          DriverManager.getConnection("jdbc:optiq:");
      OptiqConnection optiqConnection =
          connection.unwrap(OptiqConnection.class);
      final OptiqServerStatement statement =
          optiqConnection.createStatement().unwrap(OptiqServerStatement.class);
      //noinspection deprecation
      return new OptiqPrepareImpl().perform(statement, action);
    } catch (Exception e) {
View Full Code Here

        .with(
            new OptiqAssert.ConnectionFactory() {
              public OptiqConnection createConnection() throws Exception {
                final Connection connection =
                    OptiqAssert.getConnection("hr", "foodmart");
                OptiqConnection optiqConnection = connection.unwrap(
                    OptiqConnection.class);
                SchemaPlus rootSchema =
                    optiqConnection.getRootSchema();
                SchemaPlus mapSchema =
                    rootSchema.add("foo", new AbstractSchema());
View Full Code Here

        this.datasource.getPoolProperties().setSuspectTimeout(1);
        this.datasource.getPoolProperties().setLogAbandoned(true);
        Connection con = datasource.getConnection();
        assertEquals("Number of connections active/busy should be 1",1,datasource.getPool().getActive());
        Thread.sleep(3000);
        PooledConnection pcon = con.unwrap(PooledConnection.class);
        assertTrue("Connection should be marked suspect",pcon.isSuspect());
        con.close();
    }
}
View Full Code Here

  }

  @Before
  public void setUp() throws SQLException {
    Connection connection = DriverManager.getConnection("jdbc:optiq:");
    OptiqConnection optiqConnection = connection.unwrap(OptiqConnection.class);
    SchemaPlus rootSchema = optiqConnection.getRootSchema();
    rootSchema.add("test", new ReflectiveSchema(new TestSchema()));
    optiqConnection.setSchema("test");
    this.conn = optiqConnection;
  }
View Full Code Here

    try {
      Class.forName("net.hydromatic.optiq.jdbc.Driver");
      Connection connection =
          DriverManager.getConnection("jdbc:optiq:");
      OptiqConnection optiqConnection =
          connection.unwrap(OptiqConnection.class);
      final OptiqServerStatement statement =
          optiqConnection.createStatement().unwrap(OptiqServerStatement.class);
      return new OptiqPrepareImpl().perform(statement, action);
    } catch (Exception e) {
      throw new RuntimeException(e);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.