List of usage examples for org.springframework.jdbc.datasource DriverManagerDataSource DriverManagerDataSource
public DriverManagerDataSource()
From source file:edu.chalmers.dat076.moviefinder.config.RepositoryConfig.java
@Bean public DataSource dataSource() { DriverManagerDataSource ds = new DriverManagerDataSource(); ds.setDriverClassName(jdbcDriverClassName); ds.setUrl(jdbcUrl);/* w ww.jav a 2 s . c om*/ ds.setUsername(jdbcUsername); ds.setPassword(jdbcPassword); return ds; }
From source file:org.jhk.pulsing.web.service.ProdServiceConfig.java
public DataSource dataSource() { DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(env.getRequiredProperty("datasource.driver_class")); dataSource.setUrl(env.getRequiredProperty("datasource.url")); dataSource.setUsername(env.getRequiredProperty("datasource.user")); dataSource.setPassword(env.getRequiredProperty("datasource.password")); return dataSource; }
From source file:in.sc.dao.ProductHelper.java
public NamedParameterJdbcTemplate getTemplate() { if (namedParameterJdbcTemplate == null) { DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setSchema("smart_compare"); dataSource.setUsername("root"); dataSource.setPassword("root"); // dataSource.setPassword("rose@123"); dataSource.setUrl("jdbc:mysql://localhost:3306/smart_compare"); // dataSource.setURL("jdbc:mysql://52.42.111.208:3033/smart_compare"); namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); }//from w w w . j a v a 2 s. c om return namedParameterJdbcTemplate; }
From source file:com.example.DBConfig.java
@Bean public DataSource dataSource() { DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(env.getRequiredProperty(PROP_DATABASE_DRIVER)); dataSource.setUrl(env.getRequiredProperty(PROP_DATABASE_URL)); dataSource.setUsername(env.getRequiredProperty(PROP_DATABASE_USERNAME)); dataSource.setPassword(env.getRequiredProperty(PROP_DATABASE_PASSWORD)); return dataSource; }
From source file:py.una.pol.karaku.configuration.KarakuPersistence.java
/** * Crea un datasource con los valores definidos en el karaku.properties. * //www .j av a2 s.c o m * @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.sg.domain.jpa.spring.PersistenceContextConfig.java
@Bean DataSource dataSource() {/* w ww . ja v a2 s .c o m*/ DriverManagerDataSource ds = new DriverManagerDataSource(); ds.setDriverClassName(driverClassName); ds.setUrl(jdbcUrl); ds.setUsername(username); ds.setPassword(password); return ds; }
From source file:biz.wolschon.finance.jgnucash.mysql.MySQLDataSource.java
/** * {@inheritDoc}/* w ww. j a va2s. co m*/ * @see biz.wolschon.finance.jgnucash.plugin.DataSourcePlugin#loadFile() */ @Override public GnucashWritableFile loadFile() throws IOException, JAXBException { JOptionPane.showMessageDialog(null, "WARNING! MySQL-support is still incomplete"); try { com.mysql.jdbc.Driver driver = new com.mysql.jdbc.Driver(); //Class.forName("com.mysql.jdbc.Driver").newInstance(); // SimpleDriverDataSource dataSource = new SimpleDriverDataSource(driver, "jdbc:mysql://localhost/gnucash", "root", ""); DriverManagerDataSource dataSource = new DriverManagerDataSource(); ClassUtils.setDefaultClassLoader(getClassLoader()); try { dataSource.setDriverClassName("com.mysql.jdbc.Driver"); } catch (Exception e) { e.printStackTrace(); //ignored } dataSource.setUrl("jdbc:mysql://localhost/gnucash"); dataSource.setUsername("root"); dataSource.setPassword(""); return new GnucashDatabase(dataSource); } catch (Exception e) { LOG.log(Level.SEVERE, "Cannot open database-connection", e); } return null; }
From source file:com.musala.configuration.RssAplicationConfiguration.java
private DataSource createDataSource() { final DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); return dataSource; }
From source file:es.galvarez.rest.config.SpringConfiguration.java
@Bean public DataSource configureDataSource() { DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(driver); dataSource.setUrl(url);//from w w w . j a va 2s.c om dataSource.setUsername(username); dataSource.setPassword(password); return dataSource; }
From source file:org.mule.modules.basicauthsecurity.strategy.JDBCSecurityProvider.java
@Connect @TestConnectivity(label = "Test DB Configuration") public void connect(@ConnectionKey String username, @Password String password, @FriendlyName("DataBase URL") String url, String driverClassName) throws ConnectionException { managerDataSource = new DriverManagerDataSource(); managerDataSource.setUsername(username); managerDataSource.setPassword(password); managerDataSource.setUrl(url);/*from w w w .j av a 2 s . c om*/ managerDataSource.setDriverClassName(driverClassName); try { if (!managerDataSource.getConnection().isValid(1000)) { throw new ConnectionException(ConnectionExceptionCode.INCORRECT_CREDENTIALS, "Incorrect credentials", "Incorrect credentials"); } } catch (SQLException e) { throw new ConnectionException(ConnectionExceptionCode.INCORRECT_CREDENTIALS, "Incorrect credentials", "Incorrect credentials"); } jdbcUserDetailsManager = new JdbcUserDetailsManager(); setCustomQueries(); jdbcUserDetailsManager.setDataSource(managerDataSource); daoAuthenticationProvider = new DaoAuthenticationProvider(); daoAuthenticationProvider.setUserDetailsService(jdbcUserDetailsManager); List<AuthenticationProvider> list = new ArrayList<AuthenticationProvider>(); list.add(daoAuthenticationProvider); providerManager = new ProviderManager(list); }