use of io.mycat.commands.VertxMySQLDatasourcePoolImpl in project Mycat2 by MyCATApache.
the class DatasourcePoolTest method main.
@SneakyThrows
public static void main(String[] args) {
DatasourceConfig datasourceConfig = new DatasourceConfig();
datasourceConfig.setDbType("mysql");
datasourceConfig.setUser("root");
datasourceConfig.setPassword("123456");
datasourceConfig.setName("prototypeDs");
datasourceConfig.setUrl("jdbc:mysql://localhost:3307/mysql");
datasourceConfig.setMaxCon(10);
Map<String, DatasourceConfig> datasources = Maps.of("prototypeDs", datasourceConfig);
MetaClusterCurrent.register(JdbcConnectionManager.class, new JdbcConnectionManager(datasources, new DruidDatasourceProvider()));
MetaClusterCurrent.register(IOExecutor.class, IOExecutor.DEFAULT);
MycatDatasourcePool jdbcDs = new JdbcDatasourcePoolImpl("prototypeDs");
NewMycatConnection newMycatConnection = jdbcDs.getConnection().toCompletionStage().toCompletableFuture().get();
Observable<VectorSchemaRoot> observable = newMycatConnection.prepareQuery("select 1", Collections.emptyList(), new RootAllocator());
List<VectorSchemaRoot> vectorSchemaRoots = observable.toList().blockingGet();
System.out.println();
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
MycatDatasourcePool nativeDs = new VertxMySQLDatasourcePoolImpl(datasourceConfig, "prototypeDs");
MycatRelDataType sqlMycatRelType = getSqlMycatRelDataType();
TestResult testResult = getTestResult(jdbcDs);
TestResult testResult2 = getTestResult(nativeDs);
// List<String> collect = newMycatConnection.prepareQuery(querySql, Collections.emptyList()).toList().blockingGet().stream().map(i -> i.toString()).collect(Collectors.toList());
MycatRowMetaData mycatRowMetaData1 = testResult.queryResult.getMycatRowMetaData();
MycatRowMetaData mycatRowMetaData2 = testResult2.queryResult.getMycatRowMetaData();
MycatRelDataType mycatRelDataType1 = mycatRowMetaData1.getMycatRelDataType();
MycatRelDataType mycatRelDataType2 = mycatRowMetaData2.getMycatRelDataType();
System.out.println(mycatRelDataType1);
System.out.println(mycatRelDataType2);
System.out.println("=====================================================================================================");
boolean equals = mycatRelDataType1.equals(mycatRelDataType2);
// Assert.assertTrue(equals);
equals = mycatRelDataType1.equals(sqlMycatRelType);
System.out.println(sqlMycatRelType);
System.out.println(mycatRelDataType1);
observable = newMycatConnection.prepareQuery("select * from testSchema.testColumnTable", Collections.emptyList(), new RootAllocator());
vectorSchemaRoots = observable.toList().blockingGet();
System.out.println();
}
Aggregations