use of com.alibaba.druid.DbType in project druid by alibaba.
the class JdbcUtils_driver method test_log4jdbc_derby.
public void test_log4jdbc_derby() throws Exception {
String jdbcUrl = "jdbc:log4jdbc:derby://localhost:1527//db-derby-10.2.2.0-bin/databases/MyDatabase";
DbType dbType = JdbcUtils.getDbTypeRaw(jdbcUrl, "net.sf.log4jdbc.sql.jdbcapi.DriverSpy");
assertEquals("not support log4jdbc mysql, url like jdbc:log4jdbc:derby:...", DbType.derby, dbType);
}
use of com.alibaba.druid.DbType in project druid by alibaba.
the class JdbcUtils_driver method test_log4jdbc_mysql.
public void test_log4jdbc_mysql() {
String jdbcUrl = "jdbc:log4jdbc:mysql://localhost:8066/test";
DbType dbType = JdbcUtils.getDbTypeRaw(jdbcUrl, null);
assertEquals("not support log4jdbc mysql, url like jdbc:log4jdbc:mysql:...", DbType.mysql, dbType);
}
use of com.alibaba.druid.DbType in project druid by alibaba.
the class JdbcUtils_driver method test_log4jdbc_mysql2.
public void test_log4jdbc_mysql2() throws Exception {
String jdbcUrl = "jdbc:log4jdbc:mysql://localhost:8066/test";
DbType dbType = JdbcUtils.getDbTypeRaw(jdbcUrl, "net.sf.log4jdbc.DriverSpy");
assertEquals("not support log4jdbc mysql, url like jdbc:log4jdbc:mysql:...", DbType.mysql, dbType);
}
use of com.alibaba.druid.DbType in project druid by alibaba.
the class SchemaStatTest method test_schemaStat.
public void test_schemaStat() throws Exception {
String sql = "select " + " create_time_dd as 来电日期" + " from alisec_app.adl_tb_wing_rubbish_laidian_new_reason_realname_fdt " + " order by 来电日期 desc limit 30;";
DbType dbType = JdbcConstants.ODPS;
SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(sql, dbType);
SQLStatement stmt = parser.parseStatementList().get(0);
SchemaStatVisitor statVisitor = SQLUtils.createSchemaStatVisitor(dbType);
stmt.accept(statVisitor);
System.out.println(statVisitor.getColumns());
Assert.assertEquals(1, statVisitor.getColumns().size());
}
use of com.alibaba.druid.DbType in project druid by alibaba.
the class SchemaStatTest11 method test_schemaStat.
public void test_schemaStat() throws Exception {
String sql = "select a.id, b.name from (select * from table1) a inner join table2 b on a.id = b.id";
DbType dbType = JdbcConstants.ORACLE;
SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(sql, dbType);
SQLStatement stmt = parser.parseStatementList().get(0);
System.out.println(stmt);
SchemaStatVisitor statVisitor = SQLUtils.createSchemaStatVisitor(dbType);
stmt.accept(statVisitor);
Set<TableStat.Relationship> relationships = statVisitor.getRelationships();
for (TableStat.Relationship relationship : relationships) {
// table1.id = table2.id
System.out.println(relationship);
}
System.out.println(statVisitor.getColumns());
// group by
System.out.println(statVisitor.getGroupByColumns());
// group by
System.out.println("relationships : " + statVisitor.getRelationships());
System.out.println(statVisitor.getConditions());
assertEquals(1, relationships.size());
assertEquals(4, statVisitor.getColumns().size());
assertEquals(2, statVisitor.getConditions().size());
assertEquals(0, statVisitor.getFunctions().size());
assertTrue(statVisitor.containsColumn("table1", "*"));
assertTrue(statVisitor.containsColumn("table1", "id"));
assertTrue(statVisitor.containsColumn("table2", "id"));
assertTrue(statVisitor.containsColumn("table2", "name"));
}
Aggregations