本文整理汇总了Java中org.apache.calcite.avatica.ConnectionPropertiesImpl类的典型用法代码示例。如果您正苦于以下问题:Java ConnectionPropertiesImpl类的具体用法?Java ConnectionPropertiesImpl怎么用?Java ConnectionPropertiesImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionPropertiesImpl类属于org.apache.calcite.avatica包,在下文中一共展示了ConnectionPropertiesImpl类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserialize
import org.apache.calcite.avatica.ConnectionPropertiesImpl; //导入依赖的package包/类
@Override ConnectionSyncRequest deserialize(Message genericMsg) {
final Requests.ConnectionSyncRequest msg = ProtobufService.castProtobufMessage(genericMsg,
Requests.ConnectionSyncRequest.class);
String connectionId = null;
if (msg.hasField(CONNECTION_ID_DESCRIPTOR)) {
connectionId = msg.getConnectionId();
}
Meta.ConnectionProperties connProps = null;
if (msg.hasField(CONN_PROPS_DESCRIPTOR)) {
connProps = ConnectionPropertiesImpl.fromProto(msg.getConnProps());
}
return new ConnectionSyncRequest(connectionId, connProps);
}
示例2: connectionSync
import org.apache.calcite.avatica.ConnectionPropertiesImpl; //导入依赖的package包/类
@Override public ConnectionProperties connectionSync(ConnectionHandle ch,
ConnectionProperties connProps) {
LOG.trace("syncing properties for connection {}", ch);
try {
Connection conn = getConnection(ch.id);
ConnectionPropertiesImpl props = new ConnectionPropertiesImpl(conn).merge(connProps);
if (props.isDirty()) {
apply(conn, props);
props.setDirty(false);
}
return props;
} catch (SQLException e) {
throw propagate(e);
}
}
示例3: testRemoteConnectionProperties
import org.apache.calcite.avatica.ConnectionPropertiesImpl; //导入依赖的package包/类
@Test public void testRemoteConnectionProperties() throws Exception {
ConnectionSpec.getDatabaseLock().lock();
try (AvaticaConnection conn = (AvaticaConnection) DriverManager.getConnection(url)) {
String id = conn.id;
final Map<String, ConnectionPropertiesImpl> m = ((RemoteMeta) getMeta(conn)).propsMap;
assertFalse("remote connection map should start ignorant", m.containsKey(id));
// force creating a connection object on the remote side.
try (final Statement stmt = conn.createStatement()) {
assertTrue("creating a statement starts a local object.", m.containsKey(id));
assertTrue(stmt.execute("select count(1) from EMP"));
}
Connection remoteConn = getConnection(FullyRemoteJdbcMetaFactory.getInstance(), id);
final boolean defaultRO = remoteConn.isReadOnly();
final boolean defaultAutoCommit = remoteConn.getAutoCommit();
final String defaultCatalog = remoteConn.getCatalog();
final String defaultSchema = remoteConn.getSchema();
conn.setReadOnly(!defaultRO);
assertTrue("local changes dirty local state", m.get(id).isDirty());
assertEquals("remote connection has not been touched", defaultRO, remoteConn.isReadOnly());
conn.setAutoCommit(!defaultAutoCommit);
assertEquals("remote connection has not been touched",
defaultAutoCommit, remoteConn.getAutoCommit());
// further interaction with the connection will force a sync
try (final Statement stmt = conn.createStatement()) {
assertEquals(!defaultAutoCommit, remoteConn.getAutoCommit());
assertFalse("local values should be clean", m.get(id).isDirty());
}
} finally {
ConnectionSpec.getDatabaseLock().unlock();
}
}
示例4: createStatement
import org.apache.calcite.avatica.ConnectionPropertiesImpl; //导入依赖的package包/类
@Override public StatementHandle createStatement(final ConnectionHandle ch) {
return connection.invokeWithRetries(
new CallableWithoutException<StatementHandle>() {
public StatementHandle call() {
// sync connection state if necessary
connectionSync(ch, new ConnectionPropertiesImpl());
final Service.CreateStatementResponse response =
service.apply(new Service.CreateStatementRequest(ch.id));
return new StatementHandle(response.connectionId, response.statementId, null);
}
});
}
示例5: prepare
import org.apache.calcite.avatica.ConnectionPropertiesImpl; //导入依赖的package包/类
@Override public StatementHandle prepare(final ConnectionHandle ch, final String sql,
final long maxRowCount) {
return connection.invokeWithRetries(
new CallableWithoutException<StatementHandle>() {
public StatementHandle call() {
connectionSync(ch,
new ConnectionPropertiesImpl()); // sync connection state if necessary
final Service.PrepareResponse response = service.apply(
new Service.PrepareRequest(ch.id, sql, maxRowCount));
return response.statement;
}
});
}
示例6: getRequests
import org.apache.calcite.avatica.ConnectionPropertiesImpl; //导入依赖的package包/类
/**
* Generates a collection of Requests whose serialization will be tested.
*/
private static List<Request> getRequests() {
LinkedList<Request> requests = new LinkedList<>();
requests.add(new CatalogsRequest());
requests.add(new DatabasePropertyRequest());
requests.add(new SchemasRequest("connectionId", "catalog", "schemaPattern"));
requests.add(
new TablesRequest("connectionId", "catalog", "schemaPattern", "tableNamePattern",
Arrays.asList("STRING", "BOOLEAN", "INT")));
requests.add(new TableTypesRequest());
requests.add(
new ColumnsRequest("connectionId", "catalog", "schemaPattern", "tableNamePattern",
"columnNamePattern"));
requests.add(new TypeInfoRequest());
requests.add(
new PrepareAndExecuteRequest("connectionId", Integer.MAX_VALUE, "sql",
Long.MAX_VALUE));
requests.add(new PrepareRequest("connectionId", "sql", Long.MAX_VALUE));
List<TypedValue> paramValues =
Arrays.asList(TypedValue.create(Rep.BOOLEAN.name(), Boolean.TRUE),
TypedValue.create(Rep.STRING.name(), "string"));
FetchRequest fetchRequest = new FetchRequest("connectionId", Integer.MAX_VALUE,
Long.MAX_VALUE, Integer.MAX_VALUE);
requests.add(fetchRequest);
requests.add(new CreateStatementRequest("connectionId"));
requests.add(new CloseStatementRequest("connectionId", Integer.MAX_VALUE));
Map<String, String> info = new HashMap<>();
info.put("param1", "value1");
info.put("param2", "value2");
requests.add(new OpenConnectionRequest("connectionId", info));
requests.add(new CloseConnectionRequest("connectionId"));
requests.add(
new ConnectionSyncRequest("connectionId",
new ConnectionPropertiesImpl(Boolean.FALSE, Boolean.FALSE,
Integer.MAX_VALUE, "catalog", "schema")));
requests.add(new SyncResultsRequest("connectionId", 12345, getSqlQueryState(), 150));
requests.add(new SyncResultsRequest("connectionId2", 54321, getMetadataQueryState1(), 0));
requests.add(new SyncResultsRequest("connectionId3", 5, getMetadataQueryState2(), 10));
requests.add(new CommitRequest("connectionId"));
requests.add(new RollbackRequest("connectionId"));
// ExecuteBatchRequest omitted because of the special protobuf conversion it does
List<String> commands = Arrays.asList("command1", "command2", "command3");
requests.add(new PrepareAndExecuteBatchRequest("connectionId", 12345, commands));
List<ColumnMetaData> columns = Collections.emptyList();
List<AvaticaParameter> params = Collections.emptyList();
Meta.CursorFactory cursorFactory = Meta.CursorFactory.create(Style.LIST, Object.class,
Collections.<String>emptyList());
Signature signature = Signature.create(columns, "sql", params, cursorFactory,
Meta.StatementType.SELECT);
Meta.StatementHandle handle = new Meta.StatementHandle("1234", 1, signature);
requests.add(new ExecuteRequest(handle, Arrays.<TypedValue>asList((TypedValue) null), 10));
requests.add(new ExecuteRequest(handle, Arrays.asList(TypedValue.EXPLICIT_NULL), 10));
return requests;
}
示例7: getAutoCommit
import org.apache.calcite.avatica.ConnectionPropertiesImpl; //导入依赖的package包/类
public boolean getAutoCommit() throws SQLException {
if (meta.connectionSync(handle, new ConnectionPropertiesImpl()).isAutoCommit() == null)
setAutoCommit(true);
return super.getAutoCommit();
}
示例8: isReadOnly
import org.apache.calcite.avatica.ConnectionPropertiesImpl; //导入依赖的package包/类
public boolean isReadOnly() throws SQLException {
if (meta.connectionSync(handle, new ConnectionPropertiesImpl()).isReadOnly() == null)
setReadOnly(true);
return super.isReadOnly();
}