当前位置: 首页>>代码示例>>Java>>正文


Java DataSourceConfiguration类代码示例

本文整理汇总了Java中com.alexrnl.commons.database.dao.DataSourceConfiguration的典型用法代码示例。如果您正苦于以下问题:Java DataSourceConfiguration类的具体用法?Java DataSourceConfiguration怎么用?Java DataSourceConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DataSourceConfiguration类属于com.alexrnl.commons.database.dao包,在下文中一共展示了DataSourceConfiguration类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: MySQLDAOFactory

import com.alexrnl.commons.database.dao.DataSourceConfiguration; //导入依赖的package包/类
/**
 * Constructor #1.<br />
 * @param dataSourceConfiguration
 *        the data source configuration.
 */
public MySQLDAOFactory (final DataSourceConfiguration dataSourceConfiguration) {
	super(dataSourceConfiguration);
	connection = Utils.getConnection(getDataSourceConfiguration());
	
	// Instantiating all DAOs once to avoid multiple DAOs
	try {
		memberDao = new MySQLMemberDAO(connection);
		parameterDao = new MySQLParameterDAO(connection);
		partyDao = new MySQLPartyDAO(connection);
		entryMemberPartyDao = new MySQLEntryMemberPartyDAO(connection);
	} catch (final SQLException e) {
		throw new SQLConfigurationError("Error while initializing MySQL DAOs", e);
	}
	addDAO(Member.class, memberDao);
	addDAO(Parameter.class, parameterDao);
	addDAO(Party.class, partyDao);
	addDAO(EntryMemberParty.class, entryMemberPartyDao);
}
 
开发者ID:Club-Rock-ISEN,项目名称:EntryManager,代码行数:24,代码来源:MySQLDAOFactory.java

示例2: H2DAOFactory

import com.alexrnl.commons.database.dao.DataSourceConfiguration; //导入依赖的package包/类
/**
 * Constructor #1.<br />
 * @param dataSourceConfiguration
 *        the data source configuration.
 */
public H2DAOFactory (final DataSourceConfiguration dataSourceConfiguration) {
	super(dataSourceConfiguration);
	H2Utils.initDatabase(getDataSourceConfiguration());
	
	connection = Utils.getConnection(getDataSourceConfiguration());
	// Instantiating all DAOs once to avoid multiple DAOs
	try {
		memberDao = new MySQLMemberDAO(connection);
		parameterDao = new MySQLParameterDAO(connection);
		partyDao = new MySQLPartyDAO(connection);
		entryMemberPartyDao = new MySQLEntryMemberPartyDAO(connection);
	} catch (final SQLException e) {
		throw new SQLConfigurationError("Error while initializing H2 DAOs", e);
	}
	addDAO(Member.class, memberDao);
	addDAO(Parameter.class, parameterDao);
	addDAO(Party.class, partyDao);
	addDAO(EntryMemberParty.class, entryMemberPartyDao);
}
 
开发者ID:Club-Rock-ISEN,项目名称:EntryManager,代码行数:25,代码来源:H2DAOFactory.java

示例3: getConnection

import com.alexrnl.commons.database.dao.DataSourceConfiguration; //导入依赖的package包/类
/**
 * Return the connection to the database with the information specified.
 * @param dbInfos
 *        the informations to use to connect to the database.
 * @return the connection to the database.
 */
public static Connection getConnection (final DataSourceConfiguration dbInfos) {
	final Connection connection;
	try {
		connection = DriverManager.getConnection(dbInfos.getUrl(), dbInfos.getUsername(), dbInfos.getPassword());
		if (connection.isValid(0)) {
			connection.setAutoCommit(true);
			if (lg.isLoggable(Level.INFO)) {
				lg.info("Successfully connected to database " + dbInfos.getUrl());
			}
		} else {
			throw new SQLException("Database connection invalid.");
		}
	} catch (final SQLException e) {
		lg.severe("Failed to create the connection to the database " + e.getMessage());
		throw new SQLConfigurationError("Failed to connect to database: "
				+ e.getMessage(), e);
	}
	return connection;
}
 
开发者ID:Club-Rock-ISEN,项目名称:EntryManager,代码行数:26,代码来源:Utils.java

示例4: H2DAOFactory

import com.alexrnl.commons.database.dao.DataSourceConfiguration; //导入依赖的package包/类
/**
 * Constructor #1.<br />
 * @param dataSourceConfiguration
 *        the data source configuration.
 */
public H2DAOFactory (final DataSourceConfiguration dataSourceConfiguration) {
	super(dataSourceConfiguration);
	H2Utils.initDatabase(dataSourceConfiguration);
	
	try {
		connection = DriverManager.getConnection(dataSourceConfiguration.getUrl(),
				dataSourceConfiguration.getUsername(),
				dataSourceConfiguration.getPassword());
		if (connection.isValid(0)) {
			connection.setAutoCommit(true);
			if (lg.isLoggable(Level.INFO)) {
				lg.info("Connection to H2 database at " + dataSourceConfiguration.getUrl() + " is successfull");
			}
		} else {
			throw new SQLException("Connection to H2 database is not valid");
		}
		addDAO(Party.class, new PartyDAO(connection));
	} catch (final SQLException e) {
		lg.warning("Could not create H2 database connection: " + ExceptionUtils.display(e));
		throw new DataBaseConfigurationError("Error while creating H2 database connection", e);
	}
}
 
开发者ID:Club-Rock-ISEN,项目名称:EntryCounter,代码行数:28,代码来源:H2DAOFactory.java

示例5: launch

import com.alexrnl.commons.database.dao.DataSourceConfiguration; //导入依赖的package包/类
/**
 * Launch the application.<br />
 * Load the DAO configured and the services of the application.
 * Then, load the GUI show it once it is fully loaded.
 */
private void launch () {
	if (lg.isLoggable(Level.INFO)) {
		lg.info("Club Rock ISEN application starting...");
	}
	
	MainWindowController mainWindow = null;
	try {
		// Loading DAO factory and services
		final DataSourceConfiguration dbInfos = new DataSourceConfiguration(config, KEY.db().toString());
		final EntryManagerAbstractDAOFactory factory = AbstractDAOFactory.buildFactory(config.get(KEY.daoFactory()),
				dbInfos, EntryManagerAbstractDAOFactory.class);
		ServiceFactory.createFactory(config, factory);
		
		// Loading GUI
		EntryManagerFrame.setIcon(Paths.get(config.get(KEY.iconFile())));
		SwingUtils.setLookAndFeel(ServiceFactory.getImplementation().getParameterManager().get(ParametersEnum.LOOK_AND_FEEL).getValue());
		mainWindow = new MainWindowController(Paths.get(config.get(KEY.helpFile())));
		closeSplashScreen();
		mainWindow.show();
		if (lg.isLoggable(Level.INFO)) {
			lg.info("Club Rock ISEN application running.");
		}
	} catch (final TopLevelError e) {
		closeSplashScreen();
		lg.severe("Cannot run application: " + e.getClass() + "; details: " + e.getMessage());
		lg.severe("Caused by " + e.getCause());
		// Cannot use the method in view.Utils because the translator may not be loaded
		JOptionPane.showMessageDialog(null, e.getMessage(),
				"Severe error - Application will not run", JOptionPane.ERROR_MESSAGE);
		if (mainWindow != null) {
			mainWindow.dispose();
		}
	}
}
 
开发者ID:Club-Rock-ISEN,项目名称:EntryManager,代码行数:40,代码来源:App.java

示例6: getDAOFactory

import com.alexrnl.commons.database.dao.DataSourceConfiguration; //导入依赖的package包/类
/**
 * Create a new DAO factory using an in-memory database.
 * @param parentClass
 *        the parent class of the DAO factory.
 * @return the factory to use.
 * @throws URISyntaxException
 *         if the configuration file could not be loaded.
 */
public static <T extends EntryManagerAbstractDAOFactory> T getDAOFactory (final Class<T> parentClass) throws URISyntaxException {
	final Path configurationPath = Paths.get(H2DAOFactoryTest.class.getResource("/configuration.xml").toURI());
	final Configuration config = new Configuration(configurationPath);
	
	final DataSourceConfiguration dbInfos = new DataSourceConfiguration(String.format(config.get(KEY.db().url()), DB_COUNTER.incrementAndGet()),
			config.get(KEY.db().username()), config.get(KEY.db().password()),
			Paths.get(configurationPath.getParent().toString(), config.get(KEY.db().creationFile())));
	return AbstractDAOFactory.buildFactory(config.get(KEY.daoFactory()), dbInfos, parentClass);
}
 
开发者ID:Club-Rock-ISEN,项目名称:EntryManager,代码行数:18,代码来源:H2DAOFactoryTest.java

示例7: EntryManagerAbstractDAOFactory

import com.alexrnl.commons.database.dao.DataSourceConfiguration; //导入依赖的package包/类
/**
 * Constructor #1.<br />
 * @param dataSourceConfig
 *        the data source configuration.
 */
public EntryManagerAbstractDAOFactory (final DataSourceConfiguration dataSourceConfig) {
	super(dataSourceConfig);
}
 
开发者ID:Club-Rock-ISEN,项目名称:EntryManager,代码行数:9,代码来源:EntryManagerAbstractDAOFactory.java


注:本文中的com.alexrnl.commons.database.dao.DataSourceConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。