• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DataSourceConfiguration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XSLoader类代码示例发布时间:2022-05-16
下一篇:
Java IssueLinkHtmlRenderer类代码示例发布时间:2022-05-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap