List of usage examples for org.springframework.jdbc.datasource DriverManagerDataSource setDriverClassName
public void setDriverClassName(String driverClassName)
From source file:mg.jerytodik.business.config.JeryTodikConfig.java
@Bean public DataSource dataSource() { DriverManagerDataSource ds = new DriverManagerDataSource(); ds.setDriverClassName(env.getProperty("db.driver")); ds.setUrl(env.getProperty("db.url")); ds.setUsername(env.getProperty("db.username")); ds.setPassword(env.getProperty("db.password")); return ds;/*from w w w .j av a 2 s . c o m*/ }
From source file:com.wms.multitenant.tenant.provider.MultiTenantConnectionProviderImpl.java
private DataSource constructDataSource(String dbName) { DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName( 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 {/*from www . j a v a2 s .co m*/ 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:com.thesoftwareguild.flightmaster.configuration.DaoConfig.java
@Bean public DriverManagerDataSource datasource() { DriverManagerDataSource dmds = new DriverManagerDataSource(); dmds.setDriverClassName("com.mysql.jdbc.Driver"); dmds.setUrl("jdbc:mysql://localhost:3306/flights"); dmds.setUsername("root"); dmds.setPassword(""); return dmds;// w w w. j a v a 2s .c om }
From source file:edu.chalmers.dat076.moviefinder.config.RepositoryConfig.java
@Bean public DataSource dataSource() { DriverManagerDataSource ds = new DriverManagerDataSource(); ds.setDriverClassName(jdbcDriverClassName); ds.setUrl(jdbcUrl);//from www . j a v a 2 s . c o m ds.setUsername(jdbcUsername); ds.setPassword(jdbcPassword); return ds; }
From source file:io.spring.JpaApplicationTests.java
@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 {/*from w w w . ja v a 2 s . com*/ this.server = Server.createTcpServer("-tcp", "-tcpAllowOthers", "-tcpPort", String.valueOf(randomPort)) .start(); } catch (SQLException e) { throw new IllegalStateException(e); } }
From source file:com.example.spring.boot.config.DatabaseConfig.java
/** * DataSource definition for database connection. Settings are read from the * application.properties file (using the env object). */// w w w . ja v a 2s .c o m @Bean public DataSource dataSource() { DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(env.getProperty("db.driver")); dataSource.setUrl(env.getProperty("db.url")); dataSource.setUsername(env.getProperty("db.username")); dataSource.setPassword(env.getProperty("db.password")); return dataSource; }
From source file:com.ar.dev.tierra.api.config.DatabaseConfig.java
/** * Bean dataSource encargado de la configuracion de conexion con la base de * datos./*from w ww .java2s .c o m*/ * * @return objeto con la correspondiente conexion a base de datos. */ @Bean public DataSource dataSource() { DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(DB_DRIVER); dataSource.setUrl(DB_URL); dataSource.setUsername(DB_USERNAME); dataSource.setPassword(DB_PASSWORD); return dataSource; }
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:dk.nsi.minlog.export.config.DatabaseConfig.java
@Bean public DataSource dataSource() { final DriverManagerDataSource dataSource = new DriverManagerDataSource(url, username, password); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); return dataSource; }