Package net.hydromatic.optiq.jdbc

Examples of net.hydromatic.optiq.jdbc.OptiqConnection


* 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


    final List<String> schemaList = Arrays.asList(schema);
    Class.forName("net.hydromatic.optiq.jdbc.Driver");
    String suffix = schemaList.contains("spark") ? "spark=true" : "";
    Connection connection =
        DriverManager.getConnection("jdbc:optiq:" + suffix);
    OptiqConnection optiqConnection =
        connection.unwrap(OptiqConnection.class);
    SchemaPlus rootSchema = optiqConnection.getRootSchema();
    if (schemaList.contains("hr")) {
      addSchema(rootSchema, SchemaSpec.HR);
    }
    if (schemaList.contains("foodmart")) {
      addSchema(rootSchema, SchemaSpec.REFLECTIVE_FOODMART);
View Full Code Here

   */
  static OptiqConnection getConnection(boolean withClone)
      throws ClassNotFoundException, SQLException {
    Class.forName("net.hydromatic.optiq.jdbc.Driver");
    Connection connection = DriverManager.getConnection("jdbc:optiq:");
    OptiqConnection optiqConnection =
        connection.unwrap(OptiqConnection.class);
    final SchemaPlus rootSchema = optiqConnection.getRootSchema();
    addSchema(rootSchema, SchemaSpec.JDBC_FOODMART);
    if (withClone) {
      addSchema(rootSchema, SchemaSpec.CLONE_FOODMART);
    }
    optiqConnection.setSchema("foodmart2");
    return optiqConnection;
  }
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

        info.setProperty(OptiqConnectionProperty.TYPE_SYSTEM.camelName(),
            action.config.getTypeSystem().getClass().getName());
      }
      Connection connection =
          DriverManager.getConnection("jdbc:optiq:", info);
      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

        info.setProperty(OptiqConnectionProperty.TYPE_SYSTEM.camelName(),
            action.config.getTypeSystem().getClass().getName());
      }
      Connection connection =
          DriverManager.getConnection("jdbc:calcite:", info);
      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

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.