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


Java DriverManagerDataSource.setDriverClassName方法代码示例

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


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

示例1: entityManagerFactory

import org.springframework.jdbc.datasource.DriverManagerDataSource; //导入方法依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
	LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();

	JpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();

	DriverManagerDataSource dataSource = new DriverManagerDataSource();
	dataSource.setUsername("root");
	dataSource.setPassword("");
	dataSource.setUrl("jdbc:mysql://localhost:3306/ensaiospring");
	dataSource.setDriverClassName("com.mysql.jdbc.Driver");

	Properties props = new Properties();
	props.setProperty("hibernate.dialect",
			"org.hibernate.dialect.MySQL5Dialect");
	props.setProperty("hibernate.show_sql", "true");
	props.setProperty("hibernate.hbm2ddl.auto", "update");

	factory.setJpaVendorAdapter(jpaVendorAdapter);
	factory.setDataSource(dataSource);
	factory.setJpaProperties(props);
	factory.setPackagesToScan("br.com.ciaware.springmvc.ensaio.models");

	return factory;
}
 
开发者ID:flaviociaware,项目名称:cwEnsaiosWeb,代码行数:26,代码来源:JPAConfiguration.java

示例2: mysqlDataSource

import org.springframework.jdbc.datasource.DriverManagerDataSource; //导入方法依赖的package包/类
@Bean
public DataSource mysqlDataSource() {

    DriverManagerDataSource dataSource = new DriverManagerDataSource();

    dataSource.setDriverClassName(MYSQL_DRIVER_CLASS_NAME);
    dataSource.setUrl(MYSQL_URL);
    dataSource.setUsername(MYSQL_USER_NAME);
    dataSource.setPassword(MYSQL_USER_PASSWORD);

    return dataSource;
}
 
开发者ID:brainysoon,项目名称:superhouse,代码行数:13,代码来源:DataConfig.java

示例3: setup

import org.springframework.jdbc.datasource.DriverManagerDataSource; //导入方法依赖的package包/类
@Setup
public void setup() throws PropertyVetoException {
  dataSource = new DriverManagerDataSource();
  dataSource.setDriverClassName("com.mysql.jdbc.Driver");
  dataSource.setUrl(propertyOr("jdbcUrl", "jdbc:mysql://127.0.0.1:3306?useSSL=false"));
  dataSource.setUsername(propertyOr("username", "root"));
  dataSource.setPassword(propertyOr("password", "root"));

  JdbcTemplate delegate = new JdbcTemplate(dataSource);
  delegate.setDataSource(dataSource);

  proxy = new SenderProxy(new JdbcTemplateSender(delegate));
  proxy.onMessages(updated -> counter.addAndGet(updated.size()));

  reporter = reporter(proxy);
  batch = new BatchJdbcTemplate(delegate, reporter);
  batch.setDataSource(dataSource);

  unbatch = new JdbcTemplate(dataSource);
  unbatch.setDataSource(dataSource);
  unbatch.update(CREATE_DATABASE);
  unbatch.update(DROP_TABLE);
  unbatch.update(CREATE_TABLE);
}
 
开发者ID:tramchamploo,项目名称:buffer-slayer,代码行数:25,代码来源:AbstractBatchJdbcTemplateBenchmark.java

示例4: setup

import org.springframework.jdbc.datasource.DriverManagerDataSource; //导入方法依赖的package包/类
@Before
public void setup() {
	DriverManagerDataSource dataSource = new DriverManagerDataSource();
	dataSource.setDriverClassName(DATASOURCE_DRIVER_CLASS_NAME);
	dataSource.setUrl(DATASOURCE_URL);
	dataSource.setUsername(DATASOURCE_USER_NAME);
	dataSource.setPassword(DATASOURCE_USER_PASSWORD);
	this.dataSource = dataSource;
	try {
		this.server = Server.createTcpServer("-tcp", "-tcpAllowOthers", "-tcpPort", String.valueOf(randomPort))
				.start();
	}
	catch (SQLException e) {
		throw new IllegalStateException(e);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-task,代码行数:17,代码来源:JpaApplicationTests.java

示例5: getDataSource

import org.springframework.jdbc.datasource.DriverManagerDataSource; //导入方法依赖的package包/类
/**
 * @param host
 * @param port
 * @param service
 * @param user
 * @param pw
 * @return
 * @throws Exception
 */
public DriverManagerDataSource getDataSource(String host, String port, String service, String user, String pw) throws Exception
{
	// Override this method if your datasource is different
	try
	{
		DriverManagerDataSource dataSource = new DriverManagerDataSource();

		dataSource.setDriverClassName(JDBC_DRIVER);
		String url = String.format("jdbc:oracle:thin:@%s:%s:%s", host, port, service);
		dataSource.setUrl(url);
		dataSource.setUsername(user);
		dataSource.setPassword(pw);

		return dataSource;
	}
	catch (Exception e)
	{
		throw new Exception("Unable to get data source. Reason: " + e.getMessage());
	}
}
 
开发者ID:MnAnX,项目名称:Infra,代码行数:30,代码来源:JdbcEngine.java

示例6: dataSource

import org.springframework.jdbc.datasource.DriverManagerDataSource; //导入方法依赖的package包/类
/**
 * @return Access to relational database system for local deployments
 */
@Bean(name = "spring-demo-db")
public DataSource dataSource() {
    boolean isCloud = Arrays.asList(ctx.getEnvironment().getActiveProfiles()).contains("cloud");

    if (isCloud) {
        String msg = "DataSource bean has not been auto-reconfigured."
                + " Without, the application cannot exist in the Cloud.";
        logger.error(msg);
        throw new RuntimeException(msg);
    }

    logger.info("DataSource instance about to be created");
    DriverManagerDataSource ds = new DriverManagerDataSource();
    ds.setDriverClassName(env.getRequiredProperty("db.driver"));
    ds.setUrl(env.getRequiredProperty("db.url"));
    ds.setUsername(env.getRequiredProperty("db.username"));
    ds.setPassword(env.getRequiredProperty("db.password"));
    return ds;
}
 
开发者ID:IsNull,项目名称:MyBot,代码行数:23,代码来源:SpringDemoWebApplication.java

示例7: setUp

import org.springframework.jdbc.datasource.DriverManagerDataSource; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();

    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName(DRIVER);
    dataSource.setUrl(URL);
    dataSource.setUsername(USERNAME);
    dataSource.setPassword(PASSWORD);

    jdbcTemplate = new JdbcTemplate(dataSource);
    createTestSchema();

    reader.setParameters(parameters);
    reader.validate(new ArrayList<String>());
}
 
开发者ID:maxdelo77,项目名称:replyit-master-3.2-final,代码行数:17,代码来源:JDBCReaderTest.java

示例8: getNewDataSource

import org.springframework.jdbc.datasource.DriverManagerDataSource; //导入方法依赖的package包/类
/**
 * 获取新的数据源
 *
 * @return
 */
public static DataSource getNewDataSource() {
    if (newDataSource == null) synchronized (TaleUtils.class) {
        if (newDataSource == null) {
            Properties properties = TaleUtils.getPropFromFile("application-default.properties");
            if (properties.size() == 0) {
                return newDataSource;
            }
            DriverManagerDataSource managerDataSource = new DriverManagerDataSource();
            managerDataSource.setDriverClassName("com.mysql.jdbc.Driver");
            managerDataSource.setPassword(properties.getProperty("spring.datasource.password"));
            String str = "jdbc:mysql://" + properties.getProperty("spring.datasource.url") + "/" + properties.getProperty("spring.datasource.dbname") + "?useUnicode=true&characterEncoding=utf-8&useSSL=false";
            managerDataSource.setUrl(str);
            managerDataSource.setUsername(properties.getProperty("spring.datasource.username"));
            newDataSource = managerDataSource;
        }
    }
    return newDataSource;
}
 
开发者ID:ZHENFENG13,项目名称:My-Blog,代码行数:24,代码来源:TaleUtils.java

示例9: selectAnyDataSource

import org.springframework.jdbc.datasource.DriverManagerDataSource; //导入方法依赖的package包/类
@Bean
@Override
public DataSource selectAnyDataSource() {
    try {
        setProperties();
        defaultDataSource = new DriverManagerDataSource();
        defaultDataSource.setUrl(url);
        defaultDataSource.setUsername(username);
        defaultDataSource.setPassword(password);
        defaultDataSource.setDriverClassName(driver);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    System.out.println("select any :: base-multitenant-select-any");
    return defaultDataSource;
}
 
开发者ID:mojtaba-sharif,项目名称:repository-multi-tenancy,代码行数:18,代码来源:BaseMultiTenantConnectionProviderImp.java

示例10: setUp

import org.springframework.jdbc.datasource.DriverManagerDataSource; //导入方法依赖的package包/类
@Before
@Ignore
public void setUp() {
    try {
        //TODO: should be rewritten.

        DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setDriverClassName(Config.DRIVERCLASSNAME);
        dataSource.setUrl(Config.URL);
        dataSource.setUsername(Config.USERNAME);
        dataSource.setPassword(Config.PASSWORD);
        jdbc = new JdbcUserRepository(new JdbcTemplate(dataSource));
            //TODO: run creating scripts.
        Assert.assertTrue(true);
    } catch (Throwable throwable) {
        Assert.fail(throwable.getMessage());
    }
}
 
开发者ID:fedorchuck,项目名称:web-store,代码行数:19,代码来源:JdbcUserRepositoryTest.java

示例11: setUp

import org.springframework.jdbc.datasource.DriverManagerDataSource; //导入方法依赖的package包/类
@Before
@Ignore
public void setUp() {
    try {
        //TODO: should be rewritten.

        DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setDriverClassName(Config.DRIVERCLASSNAME);
        dataSource.setUrl(Config.URL);
        dataSource.setUsername(Config.USERNAME);
        dataSource.setPassword(Config.PASSWORD);
        jdbc = new JdbcCommodityRepository(new JdbcTemplate(dataSource));
        //TODO: run creating scripts.
        Assert.assertTrue(true);
    } catch (Throwable throwable) {
        Assert.fail(throwable.getMessage());
    }
}
 
开发者ID:fedorchuck,项目名称:web-store,代码行数:19,代码来源:JdbcCommodityRepositoryTest.java

示例12: rootDataSource

import org.springframework.jdbc.datasource.DriverManagerDataSource; //导入方法依赖的package包/类
@Bean(name = "rootDataSource")
public DataSource rootDataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName(environment.getRequiredProperty("jdbc.driverClassName"));
    dataSource.setUrl(environment.getRequiredProperty("jdbc.root.url"));
    dataSource.setUsername(environment.getRequiredProperty("jdbc.root.username"));
    dataSource.setPassword(environment.getRequiredProperty("jdbc.root.password"));
    return dataSource;
}
 
开发者ID:sgskinner,项目名称:StashThisBot,代码行数:10,代码来源:StashThisConfiguration.java

示例13: getSqlSearchResult

import org.springframework.jdbc.datasource.DriverManagerDataSource; //导入方法依赖的package包/类
public List<Map> getSqlSearchResult(String db, String sql) {
	DataSourceManager dataSourceManager = (DataSourceManager) ObjectLocator
			.lookup("dataSourceManager", CmsPlugin.PLUGIN_ID);
	List<Map> rs = new ArrayList<Map>();
	if (dataSourceManager != null) {
		try {
			DataSourceModel dsm = dataSourceManager.getDataSourceByName(db);
			DriverManagerDataSource dmd = new DriverManagerDataSource();
			dmd.setDriverClassName(dsm.getDriverClassName());
			dmd.setUrl(dsm.getUrl());
			dmd.setUsername(dsm.getUserName());
			dmd.setPassword(dsm.getPassword());
			BaseDaoSupport baseDao = new BaseDaoSupport();
			// 动态设置数据源
			baseDao.setDataSource(dmd);
			baseDao.setUseDataSourceDialect(true);
			rs = baseDao.getDBMapObjectList(sql);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	return rs;
}
 
开发者ID:juweiping,项目名称:ocms,代码行数:24,代码来源:AbstractCmsMacroEngine.java

示例14: getDataSource

import org.springframework.jdbc.datasource.DriverManagerDataSource; //导入方法依赖的package包/类
/**
 * Creates the data source from the settings map
 *
 * @param settingsMap - the settingMap containing the db connection settings
 * @return the DataSource object
 */
public static DataSource getDataSource(HashMap settingsMap) {
    String driver;
    if ("MySQL".equals(settingsMap.get("datasource.ojb.platform"))) {
        driver = "com.mysql.jdbc.Driver";
    } else if ("Oracle9i".equals(settingsMap.get("datasource.ojb.platform"))) {
        driver = "oracle.jdbc.driver.OracleDriver";
    } else {
        driver = (String) settingsMap.get("datasource.driver.name");
    }

    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName(driver);
    dataSource.setUrl((String) settingsMap.get("datasource.url"));
    dataSource.setUsername((String) settingsMap.get("datasource.username"));
    dataSource.setPassword((String) settingsMap.get("datasource.password"));
    return dataSource;
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:24,代码来源:FileConverter.java

示例15: setupDriverManagerDataSource

import org.springframework.jdbc.datasource.DriverManagerDataSource; //导入方法依赖的package包/类
private static void setupDriverManagerDataSource() throws NamingException{
	SimpleNamingContextBuilder builder = SimpleNamingContextBuilder
			.emptyActivatedContextBuilder();
	DriverManagerDataSource dataSource = new DriverManagerDataSource();
	dataSource.setDriverClassName(System.getProperty("usciitg.db.driver"));
	dataSource.setUrl(System.getProperty("usciitg.db"));
	dataSource.setUsername(System.getProperty("usciitg.db.user"));
	dataSource.setPassword(System.getProperty("usciitg.db.password"));

	builder.bind(System.getProperty("usciitg.datasource"), dataSource);	
}
 
开发者ID:Discovery-Research-Network-SCCM,项目名称:FHIR-CQL-ODM-service,代码行数:12,代码来源:FhirTerminologyProviderServiceIT.java


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