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


Java JdbcUtils.getDbType方法代码示例

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


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

示例1: DynamicDataSource

import com.alibaba.druid.util.JdbcUtils; //导入方法依赖的package包/类
public DynamicDataSource(MybatisNodeProperties druidNode, DruidProperties defaultDruidProperties, String dataSourceName) throws SQLException {
	this.dataSourceName=dataSourceName;
	DruidProperties master = druidNode.getMaster();
	if (master == null)
		master = new DruidProperties();
	master.merge(defaultDruidProperties).defaultEmpty().setDefaultReadOnly(false);
	this.masterDataSource = master.createDataSource();
	this.masterDataSource.setName(dataSourceName + "-Master");
	List<DruidProperties> slaves = druidNode.getSlaves();
	if (slaves != null && !slaves.isEmpty()) {
		for (int i = 0; i < slaves.size(); i++) {
			DruidProperties slave = slaves.get(i);
			if (slave == null)
				continue;
			slave.merge(defaultDruidProperties).defaultEmpty().setDefaultReadOnly(true);
			String slaveDatasourceName = dataSourceName + "-Slave-" + i;
			this.slavesDataSourceNames.add(slaveDatasourceName);
			DruidDataSource datasourc = slave.createDataSource();
			datasourc.setName(slaveDatasourceName);
			this.slaveDataSources.put(slaveDatasourceName, datasourc);
		}
	}
	String rawUrl=master.getUrl();
	String dbType = JdbcUtils.getDbType(rawUrl,null);
	this.dialect=Dialect.valoueOfName(dbType);
}
 
开发者ID:halober,项目名称:spring-boot-starter-dao,代码行数:27,代码来源:DynamicDataSource.java

示例2: getDbType

import com.alibaba.druid.util.JdbcUtils; //导入方法依赖的package包/类
protected String getDbType(DruidProperties nodeProperties, DruidProperties defaultProperties) {
	String rawUrl = nodeProperties.getUrl();
	if (StringUtils.isEmpty(nodeProperties.getUrl())) {
		rawUrl = defaultProperties.getUrl();
	}
	return JdbcUtils.getDbType(rawUrl, null);
}
 
开发者ID:halober,项目名称:spring-boot-starter-dao,代码行数:8,代码来源:AbstractDataBaseBean.java

示例3: getDbtypeByDatasource

import com.alibaba.druid.util.JdbcUtils; //导入方法依赖的package包/类
/**
* 根据数据源获取数据库类型 <br/>
* @author jingma
* @param dataSource
* @return
*/
public static String getDbtypeByDatasource(DataSource dataSource) {
    String dbType = null;
    if(dataSource instanceof DruidDataSource){
        dbType = JdbcUtils.getDbType(((DruidDataSource)dataSource).getUrl(), null);
    }else if(dataSource instanceof SJDataSource){
        dbType = JdbcUtils.getDbType(
                ((SJDataSource)dataSource).toString().split("::::")[1],
                null);
    }
    return dbType;
}
 
开发者ID:majinju,项目名称:KettleEasyExpand,代码行数:18,代码来源:Db.java

示例4: getDbtypeByDatasource

import com.alibaba.druid.util.JdbcUtils; //导入方法依赖的package包/类
/**
* 根据数据源获取数据库类型 <br/>
* @author jingma
* @param dataSource
* @return
*/
public static String getDbtypeByDatasource(DataSource dataSource) {
    String dbType = null;
    if(dataSource instanceof DruidDataSource){
        dbType = ((DruidDataSource)dataSource).getDbType();
    }else if(dataSource instanceof SJDataSource){
        dbType = JdbcUtils.getDbType(
                ((SJDataSource)dataSource).toString().split("::::")[1],
                null);
    }
    return dbType;
}
 
开发者ID:majinju,项目名称:KettleUtil,代码行数:18,代码来源:Db.java

示例5: tableBindPlugin

import com.alibaba.druid.util.JdbcUtils; //导入方法依赖的package包/类
public static TableBindPlugin tableBindPlugin(
        String configName,
        DruidPlugin druidPlugin,
        Properties dbProp
) {
    String dbUrl = dbProp.getProperty(GojaPropConst.DBURL);
    if (!Strings.isNullOrEmpty(dbUrl)) {
        String dbtype = JdbcUtils.getDbType(dbUrl, StringUtils.EMPTY);
        //  setting db table name like 'dev_info'
        final TableBindPlugin atbp = new TableBindPlugin(configName, druidPlugin);

        if (!StringUtils.equals(dbtype, JdbcConstants.MYSQL)) {
            if (StringUtils.equals(dbtype, JdbcConstants.ORACLE)) {
                atbp.setDialect(new OracleDialect());
                atbp.setContainerFactory(new CaseInsensitiveContainerFactory(true));
            } else if (StringUtils.equals(dbtype, JdbcConstants.POSTGRESQL)) {
                atbp.setDialect(new PostgreSqlDialect());
                atbp.setContainerFactory(new CaseInsensitiveContainerFactory(true));
            } else if (StringUtils.equals(dbtype, JdbcConstants.H2)) {
                atbp.setDialect(new AnsiSqlDialect());
                atbp.setContainerFactory(new CaseInsensitiveContainerFactory(true));
            } else if (StringUtils.equals(dbtype, "sqlite")) {
                atbp.setDialect(new Sqlite3Dialect());
            } else if (StringUtils.equals(dbtype, JdbcConstants.JTDS)) {
                atbp.setDialect(new SqlServerDialect());
            } else {
                System.err.println("database type is use mysql.");
            }
        }
        atbp.setShowSql(GojaConfig.getApplicationMode().isDev());
        return atbp;
    }
    return null;
}
 
开发者ID:GojaFramework,项目名称:goja,代码行数:35,代码来源:DruidDbIntializer.java

示例6: buildProperties

import com.alibaba.druid.util.JdbcUtils; //导入方法依赖的package包/类
private void buildProperties(Properties properties, MybatisNodeProperties node) throws SQLException {

		DruidProperties master = node.getMaster().defaultEmpty();
		String driverClassName = JdbcUtils.getDriverClassName(master.getUrl());
		String dbtype = JdbcUtils.getDbType(master.getUrl(), driverClassName);
		Dialect dialect = node.getDialect();
		if (null == dialect) {
			dialect = Dialect.valoueOfName(dbtype);
		}
		Mapper mapper = node.getMapper();
		if (mapper == null) {
			mapper = Mapper.valueOfDialect(dialect);
		}
		properties.setProperty("jdbc.url", master.getUrl());
		properties.setProperty("jdbc.username", master.getUsername());
		properties.setProperty("jdbc.password", master.getPassword());
		properties.setProperty("jdbc.driverClassName", driverClassName);
		properties.setProperty("jdbc.type", dbtype);
		properties.setProperty("extends.Mapper", mapper.toString());
		if (!StringUtils.hasText(properties.getProperty("extends.modelClass"))) {
			properties.setProperty("extends.modelClass", Object.class.getName());
		}
		if (!StringUtils.hasText(properties.getProperty("java.delimiter"))) {
			properties.setProperty("java.delimiter", "");
		}
		if (!StringUtils.hasText(properties.getProperty("java.encoding"))) {
			properties.setProperty("java.encoding", "UTF-8");
		}
		if (!StringUtils.hasText(properties.getProperty("package.model"))) {
			properties.setProperty("package.model", this.getFirstPackage(node.getTypeAliasesPackage()));
		}
		if (!StringUtils.hasText(properties.getProperty("package.repo"))) {
			properties.setProperty("package.repo", this.getFirstPackage(node.getBasePackage()));
		}
		if (!StringUtils.hasText(properties.getProperty("package.mapper"))) {
			String alias=this.getFirstPackage(node.getMapperPackage());
			if(StringUtils.hasText(alias)){
				alias=ClassUtils.convertClassNameToResourcePath(alias);
			}else{
				alias="";
			}
			properties.setProperty("package.mapper",alias);
		}
	}
 
开发者ID:halober,项目名称:spring-boot-starter-dao,代码行数:45,代码来源:GeneratorMain.java


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