Package net.hydromatic.optiq.jdbc

Examples of net.hydromatic.optiq.jdbc.OptiqConnection


    stmt1.execute("insert into table1 values(200, 'bar')");
    c1.close();

    // Make an optiq schema with both a jdbc schema and a non-jdbc schema
    Connection optiqConn = DriverManager.getConnection("jdbc:optiq:");
    OptiqConnection optiqConnection =
        optiqConn.unwrap(OptiqConnection.class);
    SchemaPlus rootSchema = optiqConnection.getRootSchema();
    rootSchema.add("DB",
        JdbcSchema.create(rootSchema, "DB",
            JdbcSchema.dataSource(db, "org.hsqldb.jdbcDriver", "", ""),
            null, null));
    rootSchema.add("hr", new ReflectiveSchema(new JdbcTest.HrSchema()));
View Full Code Here


        "create table table1(id varchar(10) not null primary key, "
            + "field1 varchar(10))");

    // Connect via optiq to these databases
    Connection connection = DriverManager.getConnection("jdbc:optiq:");
    OptiqConnection optiqConnection = connection.unwrap(OptiqConnection.class);
    SchemaPlus rootSchema = optiqConnection.getRootSchema();
    final DataSource ds =
        JdbcSchema.dataSource(db, "org.hsqldb.jdbcDriver", "", "");
    final SchemaPlus s =
        rootSchema.add("DB",
            JdbcSchema.create(rootSchema, "DB", ds, null, null));
View Full Code Here

          new OptiqAssert.ConnectionFactory() {
            public OptiqConnection createConnection() throws Exception {
              Class.forName("net.hydromatic.optiq.jdbc.Driver");
              Connection connection =
                  DriverManager.getConnection("jdbc:optiq:");
              OptiqConnection optiqConnection =
                  connection.unwrap(OptiqConnection.class);
              SchemaPlus rootSchema =
                  optiqConnection.getRootSchema();
              rootSchema.add(name, new ReflectiveSchema(schema));
              optiqConnection.setSchema(name);
              return optiqConnection;
            }
          });
    }
View Full Code Here

    }

    /** Creates a {@link DataContext} and executes a callback. */
    public <T> AssertThat doWithDataContext(Function1<DataContext, T> fn)
      throws Exception {
      OptiqConnection connection = connectionFactory.createConnection();
      final DataContext dataContext = MetaImpl.createDataContext(connection);
      try {
        T t = fn.apply(dataContext);
        Util.discard(t);
        return AssertThat.this;
      } finally {
        connection.close();
      }
    }
View Full Code Here

      this.schema = schema;
    }

    @Override
    public OptiqConnection createConnection() throws Exception {
      OptiqConnection connection = super.createConnection();
      connection.setSchema(schema);
      return connection;
    }
View Full Code Here

* that generates SQL statements and executes them using Optiq.
*/
public class OptiqSqlOperatorTest extends SqlOperatorBaseTest {
  private static SqlTester getHrTester() {
    try {
      OptiqConnection connection = OptiqAssert.getConnection("hr");
      return tester(connection);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

* Tests for a linq4j front-end and JDBC back-end.
*/
public class LinqFrontJdbcBackTest {
  @Test public void testTableWhere() throws SQLException,
      ClassNotFoundException {
    final OptiqConnection connection =
        OptiqAssert.getConnection(false);
    final SchemaPlus schema =
        connection.getRootSchema().getSubSchema("foodmart");
    ParameterExpression c =
        Expressions.parameter(JdbcTest.Customer.class, "c");
    String s =
        Schemas.queryable(Schemas.createDataContext(connection), schema,
            JdbcTest.Customer.class, "customer")
View Full Code Here

  /** Test case for issue 85, "Adding a table to the root schema causes breakage
   * in OptiqPrepareImpl". */
  @Test public void testAddingTableInRootSchema() throws Exception {
    Class.forName("net.hydromatic.optiq.jdbc.Driver");
    Connection connection = DriverManager.getConnection("jdbc:optiq:");
    OptiqConnection optiqConnection = connection.unwrap(OptiqConnection.class);

    optiqConnection.getRootSchema().add("SAMPLE", new SimpleTable());
    Statement statement = optiqConnection.createStatement();
    ResultSet resultSet =
        statement.executeQuery("select A, SUM(B) from SAMPLE group by A");

    assertThat(
        ImmutableMultiset.of(
View Full Code Here

  public void run() throws ClassNotFoundException, SQLException {
    Class.forName("net.hydromatic.optiq.jdbc.Driver");
    Connection connection =
        DriverManager.getConnection("jdbc:optiq:");
    OptiqConnection optiqConnection =
        connection.unwrap(OptiqConnection.class);
    SchemaPlus rootSchema = optiqConnection.getRootSchema();
    rootSchema.add("hr", new ReflectiveSchema(new Hr()));
    rootSchema.add("foodmart", new ReflectiveSchema(new Foodmart()));
    Statement statement = connection.createStatement();
    ResultSet resultSet =
        statement.executeQuery(
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

TOP

Related Classes of net.hydromatic.optiq.jdbc.OptiqConnection

Copyright © 2018 www.massapicom. 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.