List of usage examples for org.springframework.jdbc.datasource DriverManagerDataSource setUrl
public void setUrl(@Nullable String url)
From source file:se.ivankrizsan.messagecowboy.PersistenceConfiguration.java
/** * Datasource used by the Message Cowboy application. *//*from www . j av a 2 s . co m*/ @Bean public DataSource dataSource() { final DriverManagerDataSource theDataSource = new DriverManagerDataSource(); theDataSource.setDriverClassName(dataSourceDriverClassName); theDataSource.setUrl(dataSourceUrl); theDataSource.setUsername(dataSourceUserName); theDataSource.setPassword(dataSourcePassword); return theDataSource; }
From source file:org.axiom_tools.data.CloudDataSource.java
@Bean public DataSource dataSource() { int pos = Org.length(); int max = driverClassName.length() - Driver.length(); String dialect = driverClassName.substring(pos, max); String databaseURL = "jdbc:" + dialect + "://" + databaseHost + "/" + databaseName; getLogger().info(String.format(CloudDriver, driverClassName)); getLogger().info(String.format(CloudURL, databaseURL)); DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(driverClassName); dataSource.setUsername(databaseUsername); dataSource.setPassword(databasePassword); dataSource.setUrl(databaseURL); return dataSource; }
From source file:com.wms.multitenant.tenant.provider.MultiTenantConnectionProviderImpl.java
private DataSource constructDataSource(String dbName) { DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(/*from w w w .j a v a2s . c o m*/ springEnvironment.getProperty("tenant.datasource.classname", "com.mysql.jdbc.Driver")); dataSource.setUrl(springEnvironment.getProperty("tenant.datasource.url", "jdbc:mysql://localhost:3306/") + dbName + "?createDatabaseIfNotExist=true"); dataSource.setUsername(springEnvironment.getProperty("tenant.datasource.user", "root")); dataSource.setPassword(springEnvironment.getProperty("tenant.datasource.password", "root")); // ResourceDatabasePopulator rdp = new ResourceDatabasePopulator(); // rdp.populate(dataSource.getConnection()); try { dataSource.getConnection().createStatement().execute("CREATE DATABASE IF NOT EXISTS " + dbName); dataSource.getConnection().createStatement().execute("CREATE TABLE IF NOT EXISTS `product` (\n" + " `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n" + " `name` varchar(128) NOT NULL,\n" + " `product_id` varchar(128) DEFAULT NULL,\n" + " `price` double DEFAULT NULL,\n" + " `description` varchar(256) DEFAULT NULL,\n" + " `created` timestamp NULL DEFAULT NULL,\n" + " `updated` timestamp NULL DEFAULT NULL,\n" + " `deleted` timestamp NULL DEFAULT NULL,\n" + " PRIMARY KEY (`id`),\n" + " UNIQUE KEY `name` (`name`)\n" + ") ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;"); } catch (Exception ex) { System.out.println(ex); } return dataSource; }
From source file:de.alexandria.cms.config.SpringConfigBackendDatabase.java
@Bean public DataSource dataSource() { DriverManagerDataSource ds = new DriverManagerDataSource(); ds.setDriverClassName("org.postgresql.Driver"); ds.setUrl("jdbc:postgresql://" + databaseHostname + ":" + databasePort + "/" + databaseName); ds.setUsername(databaseUsername);//from w ww.ja v a 2 s . c om ds.setPassword(databasePassword); ds.setConnectionProperties(getConnectionProperties()); return ds; }
From source file:de.hska.ld.core.config.PersistenceConfig.java
@Bean public DataSource dataSource() throws SQLException { DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(env.getProperty("module.core.db.driver")); dataSource.setUrl(env.getProperty("module.core.db.url")); dataSource.setUsername(env.getProperty("module.core.db.username")); dataSource.setPassword(env.getProperty("module.core.db.password")); return dataSource; }
From source file:ca.weblite.contacts.webservice.RESTServiceConfiguration.java
@Bean public DataSource getDataSource() { if (DB_USERNAME == null || DB_PASSWORD == null || DB_URL == null) { loadRuntimeSettings();//from w ww. j a va2 s . c o m } DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUrl(DB_URL); dataSource.setUsername(DB_USERNAME); dataSource.setPassword(DB_PASSWORD); return dataSource; }
From source file:py.una.pol.karaku.configuration.KarakuPersistence.java
/** * Crea un datasource con los valores definidos en el karaku.properties. * //from w w w . jav a2 s . c om * @return dataSource creada o null si no se necesita un datasource */ @Bean public DataSource dataSource() { DriverManagerDataSource dataSource = null; if (this.enabled) { dataSource = new DriverManagerDataSource(); dataSource.setUrl(this.properties.get("database.url")); dataSource.setUsername(this.properties.get("database.user")); dataSource.setPassword(this.properties.get("database.password")); } return dataSource; }
From source file:com.anjewe.anjewewebwinkel.Config.RootConfig.java
@Bean public DataSource dataSource() throws SQLException { // drivermanagerdatasource DriverManagerDataSource ds = new DriverManagerDataSource(); ds.setDriverClassName(env.getRequiredProperty(DATABASE_DRIVER)); ds.setUsername(env.getRequiredProperty(DATABASE_USERNAME)); ds.setPassword(env.getRequiredProperty(DATABASE_PASSWORD)); ds.setUrl(env.getRequiredProperty(DATABASE_URL)); ds.setConnectionProperties(connectionProperties()); return ds;/*from w ww. j a v a2 s. c o m*/ }
From source file:com.fantasy.AggregatorConfig.java
@Bean public DataSource dataSource() { DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName("org.postgresql.Driver"); dataSource.setUrl("jdbc:postgresql://localhost:5432/fantasy"); dataSource.setUsername("postgres"); dataSource.setPassword("notorious"); return dataSource; }
From source file:org.mitre.jdbc.datasource.H2DataSourceFactory.java
protected DataSource createDataSource() { DriverManagerDataSource ds = new DriverManagerDataSource(); ds.setDriverClassName("org.h2.Driver"); ds.setUrl(getConnectionString());//from w ww .ja va2s . com ds.setUsername("sa"); ds.setPassword(""); logger.debug("Created dataSource: " + ds.toString()); return ds; }