Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package nl.avans.ivh5a1.proftaak.config; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Profile; import org.springframework.core.env.Environment; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.transaction.annotation.EnableTransactionManagement; import javax.annotation.Resource; import javax.sql.DataSource; import nl.avans.ivh5a1.proftaak.client.ClientRepository; import nl.avans.ivh5a1.proftaak.insurancecompany.InsuranceCompanyRepository; import nl.avans.ivh5a1.proftaak.policy.PolicyRepository; /** * @author Petri Kainulainen * * Dit bestand bevat database settings voor het starten van de applicatie. */ @SuppressWarnings("Duplicates") @Profile("default") @Configuration @EnableTransactionManagement public class PersistenceContext { protected static final String PROPERTY_NAME_DATABASE_DRIVER = "com.mysql.jdbc.Driver"; protected static final String PROPERTY_NAME_DATABASE_PASSWORD = "ivh5a1"; protected static final String PROPERTY_NAME_DATABASE_URL = "jdbc:mysql://95.85.26.238:3306/ivh5"; protected static final String PROPERTY_NAME_DATABASE_USERNAME = "ivh5a1"; private static final String PROPERTY_PACKAGES_TO_SCAN = "nl.avans.ivh5a1.proftaak.config"; @Resource private Environment environment; @Bean public DataSource dataSource() { DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(PROPERTY_NAME_DATABASE_DRIVER); dataSource.setUrl(PROPERTY_NAME_DATABASE_URL); dataSource.setUsername(PROPERTY_NAME_DATABASE_USERNAME); dataSource.setPassword(PROPERTY_NAME_DATABASE_PASSWORD); return dataSource; } }