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


Java TransactionalDriver类代码示例

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


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

示例1: shouldGetConnectionAndCommit

import com.arjuna.ats.jdbc.TransactionalDriver; //导入依赖的package包/类
@Test
public void shouldGetConnectionAndCommit() throws SQLException {
	Connection mockConnection = mock(Connection.class);
	XAConnection mockXaConnection = mock(XAConnection.class);
	given(mockXaConnection.getConnection()).willReturn(mockConnection);
	given(this.dataSource.getXAConnection()).willReturn(mockXaConnection);

	Properties properties = new Properties();
	properties.put(TransactionalDriver.XADataSource, this.dataSource);

	Connection connection = this.dataSourceBean.getConnection();
	assertThat(connection).isInstanceOf(ConnectionImple.class);

	connection.commit();

	verify(this.dataSource, times(1)).getXAConnection();
	verify(mockXaConnection, times(1)).getConnection();
	verify(mockConnection, times(1)).commit();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:NarayanaDataSourceBeanTests.java

示例2: shouldGetConnectionAndCommitWithCredentials

import com.arjuna.ats.jdbc.TransactionalDriver; //导入依赖的package包/类
@Test
public void shouldGetConnectionAndCommitWithCredentials() throws SQLException {
	String username = "testUsername";
	String password = "testPassword";
	Connection mockConnection = mock(Connection.class);
	XAConnection mockXaConnection = mock(XAConnection.class);
	given(mockXaConnection.getConnection()).willReturn(mockConnection);
	given(this.dataSource.getXAConnection(username, password))
			.willReturn(mockXaConnection);

	Properties properties = new Properties();
	properties.put(TransactionalDriver.XADataSource, this.dataSource);
	properties.put(TransactionalDriver.userName, username);
	properties.put(TransactionalDriver.password, password);

	Connection connection = this.dataSourceBean.getConnection(username, password);
	assertThat(connection).isInstanceOf(ConnectionImple.class);

	connection.commit();

	verify(this.dataSource, times(1)).getXAConnection(username, password);
	verify(mockXaConnection, times(1)).getConnection();
	verify(mockConnection, times(1)).commit();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:25,代码来源:NarayanaDataSourceBeanTests.java

示例3: getConnection

import com.arjuna.ats.jdbc.TransactionalDriver; //导入依赖的package包/类
@Override
public Connection getConnection(String username, String password)
		throws SQLException {
	Properties properties = new Properties();
	properties.put(TransactionalDriver.XADataSource, this.xaDataSource);
	properties.put(TransactionalDriver.userName, username);
	properties.put(TransactionalDriver.password, password);
	return ConnectionManager.create(null, properties);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:NarayanaDataSourceBean.java

示例4: getDataSource

import com.arjuna.ats.jdbc.TransactionalDriver; //导入依赖的package包/类
public synchronized XADataSource getDataSource(String dbName, boolean create) throws SQLException {
	try {
		MysqlXADataSource xads = new MysqlXADataSource();
		int index1 = dbName.indexOf(Mysql.driverName);

		if (index1 == -1) {
			// throw new SQLException("Mysql.getDataSource -
			// "+jdbcLogger.logMesg.getString("com.arjuna.ats.internal.jdbc.drivers.invaliddb")+"
			// Mysql");
			throw new SQLException("Mysql.getDataSource - " + dbName);
		} else {
			/*
			 * Strip off any spurious parameters.
			 */

			int index2 = dbName.indexOf(Mysql.semicolon);
			String theDbName = null;

			if (index2 == -1) {
				theDbName = dbName.substring(index1 + Mysql.driverName.length());
			} else {
				theDbName = dbName.substring(index1 + Mysql.driverName.length(), index2);
			}

			System.out.println("URL->" + TransactionalDriver.jdbc + Mysql.driverName + theDbName);

			xads.setURL(TransactionalDriver.jdbc + Mysql.driverName + theDbName);

			return xads;
		}
	} catch (SQLException e1) {
		throw e1;
	} catch (Exception e2) {
		// throw new SQLException("Mysql
		// "+jdbcLogger.logMesg.getString("com.arjuna.ats.internal.jdbc.drivers.exception")+e2);
		throw new SQLException("Mysql " + e2);
	}
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:39,代码来源:Mysql.java


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