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


Java OceanbaseDataSourceProxy类代码示例

本文整理汇总了Java中com.alipay.oceanbase.OceanbaseDataSourceProxy的典型用法代码示例。如果您正苦于以下问题:Java OceanbaseDataSourceProxy类的具体用法?Java OceanbaseDataSourceProxy怎么用?Java OceanbaseDataSourceProxy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: main

import com.alipay.oceanbase.OceanbaseDataSourceProxy; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        Date gmt = new Date(1350304585380l);
        long start = System.currentTimeMillis();
        OceanbaseDataSourceProxy ds = new OceanbaseDataSourceProxy();
        ds.setConfigURL("http://obconsole.test.alibaba-inc.com/ob-config/config.co?dataId=wireless_message");
        ds.init();
        System.out.println("init done");

        Connection conn = ds.getConnection();

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

        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();

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

示例2: doInit

import com.alipay.oceanbase.OceanbaseDataSourceProxy; //导入依赖的package包/类
@Override
public void doInit() {
    this.config = new RepositoryConfig();
    this.config.setProperty(RepositoryConfig.DEFAULT_TXN_ISOLATION, "READ_COMMITTED");
    this.config.setProperty(RepositoryConfig.IS_TRANSACTIONAL, "true");
    cfm = new ObCursorFactory();
    cef = new ObCommandHandlerFactory();

    tables = CacheBuilder.newBuilder().build(new CacheLoader<String, LoadingCache<TableMeta, ITable>>() {

        @Override
        public LoadingCache<TableMeta, ITable> load(final String groupNode) throws Exception {
            return CacheBuilder.newBuilder().build(new CacheLoader<TableMeta, ITable>() {

                @Override
                public ITable load(TableMeta meta) throws Exception {
                    try {

                        DataSource ds = dsGetter.getDataSource(groupNode);
                        Ob_Table table = new Ob_Table(ds, meta, groupNode);
                        table.setSelect(false);
                        return table;
                    } catch (Exception ex) {
                        throw new TddlNestableRuntimeException(ex);
                    }
                }

            });
        }
    });

    executors = CacheBuilder.newBuilder().build(new CacheLoader<Group, IGroupExecutor>() {

        @Override
        public IGroupExecutor load(Group group) throws Exception {
            OceanbaseDataSourceProxy obDS = new OceanbaseDataSourceProxy();
            String configUrl = group.getProperties().get(CONFIG_URL);

            if (configUrl == null) {
                throw new IllegalArgumentException("config url is not assigned, oceanbase datasource cannot be inited");
            }

            obDS.setConfigURL(configUrl);
            obDS.init();

            ObGroupExecutor executor = new ObGroupExecutor(getRepo());
            executor.setGroup(group);
            executor.setGroupDataSource(new OBDataSourceWrapper(obDS));
            return executor;
        }
    });
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:53,代码来源:Ob_Repository.java

示例3: OBDataSourceWrapper

import com.alipay.oceanbase.OceanbaseDataSourceProxy; //导入依赖的package包/类
public OBDataSourceWrapper(OceanbaseDataSourceProxy ds){
    this.ds = ds;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:4,代码来源:OBDataSourceWrapper.java

示例4: getRemotingExecutableObject

import com.alipay.oceanbase.OceanbaseDataSourceProxy; //导入依赖的package包/类
@Override
public OceanbaseDataSourceProxy getRemotingExecutableObject() {
    return groupDataSource;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:5,代码来源:ObGroupExecutor.java

示例5: setGroupDataSource

import com.alipay.oceanbase.OceanbaseDataSourceProxy; //导入依赖的package包/类
public void setGroupDataSource(OceanbaseDataSourceProxy ds) {
    this.groupDataSource = ds;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:4,代码来源:ObGroupExecutor.java

示例6: doInit

import com.alipay.oceanbase.OceanbaseDataSourceProxy; //导入依赖的package包/类
@Override
public void doInit() {
    this.config = new RepositoryConfig();
    this.config.setProperty(RepositoryConfig.DEFAULT_TXN_ISOLATION, "READ_COMMITTED");
    this.config.setProperty(RepositoryConfig.IS_TRANSACTIONAL, "true");
    cfm = new ObCursorFactory();
    cef = new ObCommandHandlerFactory();

    tables = CacheBuilder.newBuilder().build(new CacheLoader<String, LoadingCache<TableMeta, ITable>>() {

        @Override
        public LoadingCache<TableMeta, ITable> load(final String groupNode) throws Exception {
            return CacheBuilder.newBuilder().build(new CacheLoader<TableMeta, ITable>() {

                @Override
                public ITable load(TableMeta meta) throws Exception {
                    try {
                        DataSource ds = dsGetter.getDataSource(groupNode);
                        Ob_Table table = new Ob_Table(ds, meta, groupNode);
                        table.setSelect(false);
                        return table;
                    } catch (Exception ex) {
                        throw new TddlException(ExceptionErrorCodeUtils.Read_only, ex);
                    }
                }

            });
        }
    });

    executors = CacheBuilder.newBuilder().build(new CacheLoader<Group, IGroupExecutor>() {

        @Override
        public IGroupExecutor load(Group group) throws Exception {
            OceanbaseDataSourceProxy obDS = new OceanbaseDataSourceProxy();
            String configUrl = group.getProperties().get(CONFIG_URL);

            if (configUrl == null) {
                throw new TddlRuntimeException("config url is not assigned, oceanbase datasource cannot be inited");
            }

            obDS.setConfigURL(configUrl);
            obDS.init();

            TddlGroupExecutor executor = new TddlGroupExecutor(getRepo());
            executor.setGroup(group);
            executor.setRemotingExecutableObject(obDS);
            return executor;
        }
    });
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:52,代码来源:Ob_Repository.java


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