當前位置: 首頁>>代碼示例>>Java>>正文


Java DriverManagerDataSource.setPassword方法代碼示例

本文整理匯總了Java中org.springframework.jdbc.datasource.DriverManagerDataSource.setPassword方法的典型用法代碼示例。如果您正苦於以下問題:Java DriverManagerDataSource.setPassword方法的具體用法?Java DriverManagerDataSource.setPassword怎麽用?Java DriverManagerDataSource.setPassword使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.jdbc.datasource.DriverManagerDataSource的用法示例。


在下文中一共展示了DriverManagerDataSource.setPassword方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: createDataSource

import org.springframework.jdbc.datasource.DriverManagerDataSource; //導入方法依賴的package包/類
/**
 * Creates and returns a new data source from the given connection information. Creates a new {@link DriverManagerDataSource}.
 *
 * @param jdbcConnection the JDBC connection
 * @param variables the optional map of key-value for expression evaluation
 *
 * @return a new {@link DataSource}
 */
private DataSource createDataSource(JdbcConnection jdbcConnection, Map<String, Object> variables)
{
    String url = evaluate(jdbcConnection.getUrl(), variables, "jdbc connection url");
    String username = evaluate(jdbcConnection.getUsername(), variables, "jdbc connection username");
    String password = evaluate(jdbcConnection.getPassword(), variables, "jdbc connection password");

    validateUrl(url);

    DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource();
    driverManagerDataSource.setUrl(url);
    driverManagerDataSource.setUsername(username);
    driverManagerDataSource.setPassword(password);
    driverManagerDataSource.setDriverClassName(getDriverClassName(jdbcConnection.getDatabaseType()));
    return driverManagerDataSource;
}
 
開發者ID:FINRAOS,項目名稱:herd,代碼行數:24,代碼來源:JdbcServiceImpl.java

示例4: dataSource

import org.springframework.jdbc.datasource.DriverManagerDataSource; //導入方法依賴的package包/類
@Bean(name = "dataSource")
public DataSource dataSource() {
    DriverManagerDataSource ds = new DriverManagerDataSource();
    ds.setDriverClassName(driverClassName);
    ds.setUrl(databaseUrl);

    Properties p = new Properties();
    Map<String, String> datasourceProperties = mapPropertyNames("datasource", hibernateConfiguration());
    p.putAll(datasourceProperties);
    ds.setConnectionProperties(p);
    if (!StringUtils.isEmpty(username)) {
        ds.setUsername(username);
    }
    if (!StringUtils.isEmpty(password)) {
        ds.setPassword(password);
    }
    return ds;
}
 
開發者ID:thunderbird,項目名稱:pungwecms,代碼行數:19,代碼來源:JPAConfiguration.java

示例5: configureDataSource

import org.springframework.jdbc.datasource.DriverManagerDataSource; //導入方法依賴的package包/類
@Bean
public DataSource configureDataSource() {
    log.info("*************** Env Variables configureDataSource *************** ");

    String driver = System.getenv(EnviromentVariables.DATASOURCE_DRIVER_CLASS.getCode());
    String url = System.getenv(EnviromentVariables.DATASOURCE_URL.getCode());
    String username = System.getenv(EnviromentVariables.DATASOURCE_USERNAME.getCode());
    String password = System.getenv(EnviromentVariables.DATASOURCE_PASSWORD.getCode());

    log.info("dataSource.driverClassName:    " + driver);
    log.info("dataSource.url:                " + url);
    log.info("dataSource.username:           " + username);
    log.info("dataSource.password:           ***");

    log.info("*************** END Env Variables configureDataSource *************** ");

    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName(driver);
    dataSource.setUrl(url);
    dataSource.setUsername(username);
    dataSource.setPassword(password);

    return dataSource;
}
 
開發者ID:macielbombonato,項目名稱:apolo,代碼行數:25,代碼來源:PersistenceConfig.java

示例6: 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

示例7: 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

示例8: 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:kuali,項目名稱:rice,代碼行數:24,代碼來源:FileConverter.java

示例9: 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

示例10: 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

示例11: 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

示例12: getH2DataSource

import org.springframework.jdbc.datasource.DriverManagerDataSource; //導入方法依賴的package包/類
@Bean(name = "dataSource")
public DataSource getH2DataSource() 
{
	System.out.println("Starting of the method getH2DataSource");
	DriverManagerDataSource dataSource = new DriverManagerDataSource();
	dataSource.setDriverClassName("org.h2.Driver");
	dataSource.setUrl("jdbc:h2:tcp://localhost/~/bookmanagementsystem");
	dataSource.setUsername("sa");
	dataSource.setPassword("@aakash");
	System.out.println("Data Source Creation");
	return dataSource;
}
 
開發者ID:AakashOfficial,項目名稱:Book-Management,代碼行數:13,代碼來源:DBConfig.java

示例13: 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

示例14: 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

示例15: 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


注:本文中的org.springframework.jdbc.datasource.DriverManagerDataSource.setPassword方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。