当前位置: 首页>>代码示例>>Java>>正文


Java TDataSource.setRuleFile方法代码示例

本文整理汇总了Java中com.taobao.tddl.matrix.jdbc.TDataSource.setRuleFile方法的典型用法代码示例。如果您正苦于以下问题:Java TDataSource.setRuleFile方法的具体用法?Java TDataSource.setRuleFile怎么用?Java TDataSource.setRuleFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.taobao.tddl.matrix.jdbc.TDataSource的用法示例。


在下文中一共展示了TDataSource.setRuleFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.taobao.tddl.matrix.jdbc.TDataSource; //导入方法依赖的package包/类
public static void main(String[] args) throws TddlException, SQLException, FileNotFoundException {
    Log4jConfigurer.initLogging("src/main/resources/log4j.properties");

    TDataSource ds = new TDataSource();

    // 设置默认db(ob)
    ds.setAppName("DEV_DPS_APP");
    ds.setTopologyFile("tddl-topology-dps.xml");
    ds.setRuleFile("tddl-rule-dps-nonmysql.xml");

    // 设置simba2的mysql
    App subApp = new App();
    subApp.setAppName("DAILY_SOLAR_MERCURY_APP");
    subApp.setRuleFile("tddl-rule-dps-simba2-mysql.xml");
    ds.addSubApp(subApp);

    // 添加subway的mysql
    subApp = new App();
    subApp.setAppName("DEV_SUBWAY_MYSQL");
    subApp.setRuleFile("tddl-rule-dps-subway-mysql.xml");
    ds.addSubApp(subApp);

    Map cp = new HashMap();
    cp.put("ALLOW_TEMPORARY_TABLE", "True");
    cp.put(ConnectionProperties.TEMP_TABLE_DIR, ".\\temp\\");
    cp.put(ConnectionProperties.TEMP_TABLE_CUT_ROWS, false);
    cp.put(ConnectionProperties.TEMP_TABLE_MAX_ROWS, 1000);
    ds.setConnectionProperties(cp);

    ds.init();
    System.out.println("init done");

    // subway_adgroup_list.sql
    // solar_adgroup_list.sql
    String sql = SqlFileUtil.getSql("replace.txt");
    // sql = SqlFileUtil.getSql("solar_adgroup_list.sql");
    Connection conn = ds.getConnection();
    {
        PreparedStatement ps = conn.prepareStatement(sql);
        long start = System.currentTimeMillis();
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            StringBuilder sb = new StringBuilder();
            int count = rs.getMetaData().getColumnCount();
            for (int i = 1; i <= count; i++) {

                String key = rs.getMetaData().getColumnLabel(i);
                Object val = rs.getObject(i);
                sb.append("[" + rs.getMetaData().getTableName(i) + "." + key + "->" + val + "]");
            }
            System.out.println(sb.toString());
        }
        System.out.println("done " + (System.currentTimeMillis() - start));
        rs.close();
        ps.close();
    }

    conn.close();
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:60,代码来源:Simba2Sample.java

示例2: JDBCClient

import com.taobao.tddl.matrix.jdbc.TDataSource; //导入方法依赖的package包/类
public static void JDBCClient(String dbTypeStack, boolean async) throws Exception {
    us = new TDataSource();
    // if ("tddl".equalsIgnoreCase(dbTypeStack) ||
    // "mysql".equalsIgnoreCase(dbTypeStack)) {
    us.setAppName("andor_mysql_qatest");
    // } else if ("tdhs".equalsIgnoreCase(dbTypeStack)) {
    // us.setAppName("andor_tdhs_qatest");
    // } else if ("hbase".equalsIgnoreCase(dbTypeStack)) {
    // us.setAppName("andor_hbase_qatest");
    // }

    us.setRuleFile(ruleFile + dbTypeStack + "_" + rule);

    if ((!"tddl".equalsIgnoreCase(dbTypeStack)) && (!"tdhs".equalsIgnoreCase(dbTypeStack))) {
        us.setTopologyFile(machineTapologyFile);
        us.setSchemaFile(schemaFile + dbTypeStack + "_" + schema);
    }

    Map<String, Object> cp = new HashMap<String, Object>();
    if ("tdhs".equalsIgnoreCase(dbTypeStack)) {
        cp.put(ExtraCmd.USE_TDHS_FOR_DEFAULT, "true");
    }

    if ("hbase".equalsIgnoreCase(dbTypeStack)) {
        cp.put(ExtraCmd.HBASE_MAPPING_FILE, "matrix/hbase_mapping.xml");
    }
    us.setConnectionProperties(cp);
    try {
        us.init();
    } catch (Exception e) {
        Assert.fail(ExceptionUtils.getFullStackTrace(e));
    }
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:34,代码来源:BaseMatrixTestCase.java

示例3: main

import com.taobao.tddl.matrix.jdbc.TDataSource; //导入方法依赖的package包/类
public static void main(String[] args) throws TddlException, SQLException {

        TDataSource ds = new TDataSource();

        // init a datasource with local config file
        ds.setAppName("tddl5_sample");
        ds.setRuleFile("classpath:sample_rule.xml");
        ds.setTopologyFile("sample_topology.xml");
        ds.setSchemaFile("test_schema.xml");
        ds.init();

        System.out.println("init done");

        Connection conn = ds.getConnection();

        // insert a record
        conn.prepareStatement("replace into sample_table (id,name,address) values (1,'sun','hz')").executeUpdate();

        System.out.println("insert done");

        // select all records
        PreparedStatement ps = conn.prepareStatement("SELECT * from sample_table");

        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            StringBuilder sb = new StringBuilder();
            int count = rs.getMetaData().getColumnCount();
            for (int i = 1; i <= count; i++) {

                String key = rs.getMetaData().getColumnLabel(i);
                Object val = rs.getObject(i);
                sb.append("[" + rs.getMetaData().getTableName(i) + "." + key + "->" + val + "]");
            }
            System.out.println(sb.toString());
        }

        rs.close();
        ps.close();
        conn.close();

        System.out.println("query done");
    }
 
开发者ID:loye168,项目名称:tddl5,代码行数:43,代码来源:LocalConfigSample.java

示例4: main

import com.taobao.tddl.matrix.jdbc.TDataSource; //导入方法依赖的package包/类
public static void main(String[] args) throws TddlException, SQLException {

        TDataSource ds = new TDataSource();

        // init a datasource with local config file
        ds.setAppName("tddl5_sample");
        ds.setRuleFile("classpath:sample_rule.xml");
        ds.setTopologyFile("sample_topology.xml");
        ds.setSchemaFile("demo_repo_schema.xml");
        ds.init();

        System.out.println("init done");

        Connection conn = ds.getConnection();

        // insert a record
        conn.prepareStatement("replace into _tddl_ (id,name) values (1,'sun1')").executeUpdate();
        conn.prepareStatement("replace into _tddl_ (id,name) values (2,'sun1')").executeUpdate();

        conn.prepareStatement("replace into _tddl_ (id,name) values (3,'sun1')").executeUpdate();

        conn.prepareStatement("replace into _tddl_ (id,name) values (4,'sun2')").executeUpdate();

        conn.prepareStatement("replace into _tddl_ (id,name) values (5,'sun2')").executeUpdate();

        System.out.println("insert done");

        // select all records
        PreparedStatement ps = conn.prepareStatement("SELECT id from _tddl_ order by id");
        // PreparedStatement ps =
        // conn.prepareStatement("SELECT * from _tddl_ t1 join _tddl_ t2 where t1.name=t2.name and t2.name='sun1' and t1.id=1");

        // PreparedStatement ps =
        // conn.prepareStatement("SELECT * from _tddl_ t1 where name='sun'");

        // PreparedStatement ps =
        // conn.prepareStatement("SELECT count(*)+1 from _tddl_ t1 where t1.id=1");
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            StringBuilder sb = new StringBuilder();
            int count = rs.getMetaData().getColumnCount();
            for (int i = 1; i <= count; i++) {

                String key = rs.getMetaData().getColumnLabel(i);
                Object val = rs.getObject(i);
                sb.append("[" + rs.getMetaData().getTableName(i) + "." + key + "->" + val + "]");
            }
            System.out.println(sb.toString());
        }

        rs.close();
        ps.close();
        conn.close();

        System.out.println("query done");
    }
 
开发者ID:loye168,项目名称:tddl5,代码行数:57,代码来源:DemoRepoSample.java

示例5: main

import com.taobao.tddl.matrix.jdbc.TDataSource; //导入方法依赖的package包/类
public static void main(String[] args) throws TddlException, SQLException {

        TDataSource ds = new TDataSource();

        // init a datasource with dynamic config on diamond
        ds.setAppName("BULLET_APP");
        ds.setRuleFile("xuezhu.xml");

        ds.init();

        System.out.println("init done");

        Connection conn = ds.getConnection();

        System.out.println("insert done");

        // select all records
        PreparedStatement ps = conn.prepareStatement("SELECT sum(TO_SECONDS(end_time)-TO_SECONDS(start_time)) as totalTime from bullet_dt_device_content where device_id>0 LIMIT 10");
        // PreparedStatement ps =
        // conn.prepareStatement("SELECT device_id from bullet_dt_device_content  limit 10");

        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            StringBuilder sb = new StringBuilder();
            int count = rs.getMetaData().getColumnCount();
            for (int i = 1; i <= count; i++) {

                String key = rs.getMetaData().getColumnLabel(i);
                Object val = rs.getObject(i);
                sb.append("[" + rs.getMetaData().getTableName(i) + "." + key + "->" + val + "]");
            }
            System.out.println(sb.toString());
        }

        rs.close();
        ps.close();
        conn.close();

        System.out.println("query done");

    }
 
开发者ID:loye168,项目名称:tddl5,代码行数:42,代码来源:XuezhuSample.java


注:本文中的com.taobao.tddl.matrix.jdbc.TDataSource.setRuleFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。