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

Java CannotGetJdbcConnectionException类代码示例

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

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



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

示例1: doTestCouldntGetConnectionInOperationWithExceptionTranslatorInitialized

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
/**
 * If beanProperty is true, initialize via exception translator bean property;
 * if false, use afterPropertiesSet().
 */
private void doTestCouldntGetConnectionInOperationWithExceptionTranslatorInitialized(boolean beanProperty)
		throws SQLException {
	SQLException sqlException = new SQLException("foo", "07xxx");
	this.dataSource = mock(DataSource.class);
	given(this.dataSource.getConnection()).willThrow(sqlException);
	this.template = new JdbcTemplate();
	this.template.setDataSource(this.dataSource);
	this.template.setLazyInit(false);
	if (beanProperty) {
		// This will get a connection.
		this.template.setExceptionTranslator(new SQLErrorCodeSQLExceptionTranslator(this.dataSource));
	}
	else {
		// This will cause creation of default SQL translator.
		this.template.afterPropertiesSet();
	}
	RowCountCallbackHandler rcch = new RowCountCallbackHandler();
	this.thrown.expect(CannotGetJdbcConnectionException.class);
	this.thrown.expect(exceptionCause(sameInstance(sqlException)));
	this.template.query("SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3", rcch);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:JdbcTemplateTests.java


示例2: update

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
@Override
public int update(JdbcTemplate jdbcTemplate, String sql)
{
    LOGGER.debug("sql = " + sql);
    if (CASE_1_SQL.equals(sql))
    {
        return 1;
    }
    else if (CASE_2_SQL.equals(sql))
    {
        throw new DataIntegrityViolationException("test", new SQLException("test DataIntegrityViolationException cause"));
    }
    else if (CASE_3_SQL.equals(sql))
    {
        throw new CannotGetJdbcConnectionException("test", new SQLException("test CannotGetJdbcConnectionException cause"));
    }

    return 0;
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:20,代码来源:MockJdbcOperations.java


示例3: searchSimp

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
public <T> List<T> searchSimp(Class<T> clz,int start,int size,int flag,Object startObj,Object endObj,String... ranges) throws Exception
{
	try {
		return DBUtil.search(this.isOrcl,true, dbop, DBUtil.getTableNameEx(clz), start, size, flag, startObj, endObj, clz, ranges);
	} catch (Exception e) {
		if(e instanceof DataAccessException||e instanceof CannotGetJdbcConnectionException){
			 if(notify==null){
				 notify=MTSystemService.getInstance().getNotifyService();
			 }
			 notify.initData(null, e,SpringUtil.getApplicationContext().getApplicationName());
			 executor.execute(notify);
		 }
		e.printStackTrace();
		throw e;
	}
}
 
开发者ID:zhanggh,项目名称:mtools,代码行数:17,代码来源:CoreDao.java


示例4: countSimp

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
public <T> long countSimp(Class<T> clz,int flag,Object startObj,Object endObj,String... ranges) throws Exception
{
	try {
		return DBUtil.count(true, dbop, DBUtil.getTableNameEx(clz), flag, startObj, endObj, clz, ranges);
	} catch (Exception e) {
		if(e instanceof DataAccessException||e instanceof CannotGetJdbcConnectionException){
			 if(notify==null){
				 notify=MTSystemService.getInstance().getNotifyService();
			 } 
			 notify.initData(null, e,SpringUtil.getApplicationContext().getApplicationName());
			 executor.execute(notify);
		 }
		e.printStackTrace();
		throw e;
	}
}
 
开发者ID:zhanggh,项目名称:mtools,代码行数:17,代码来源:CoreDao.java


示例5: searchForArray

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
public List<Object[]> searchForArray(String sql,Object...args) throws Exception
{
	try {
		return DBUtil.getListForArray(dbop, sql, args);
	} catch (Exception e) {
		if(e instanceof DataAccessException||e instanceof CannotGetJdbcConnectionException){
			 if(notify==null){
				 notify=MTSystemService.getInstance().getNotifyService();
			 } 
			 notify.initData(null, e,SpringUtil.getApplicationContext().getApplicationName());
			 executor.execute(notify);
		 }
		e.printStackTrace();
		throw e;
	}
}
 
开发者ID:zhanggh,项目名称:mtools,代码行数:17,代码来源:CoreDao.java


示例6: add

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
public int add(Object obj) throws Exception{
	try {
		String tableName = DBUtil.getTableName(obj);
		if(tableName!=null)
			return DBUtil.insertObj(true,dbop, tableName, obj);
		else
			return 0;
	} catch (Exception e) {
		if(e instanceof DataAccessException||e instanceof CannotGetJdbcConnectionException){
			 if(notify==null){
				 notify=MTSystemService.getInstance().getNotifyService();
			 } 
			 notify.initData(null, e,SpringUtil.getApplicationContext().getApplicationName());
			 executor.execute(notify);
		 }
		e.printStackTrace();
		throw e;
	}
}
 
开发者ID:zhanggh,项目名称:mtools,代码行数:20,代码来源:CoreDao.java


示例7: addBatch

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
public int[] addBatch(Object...objects) throws Exception{
	try {
		String tableName = null;
		if(objects==null||objects.length==0)
			return null;
		else
			tableName = DBUtil.getTableName(objects[0]);
		if(tableName!=null)
			return DBUtil.insertObjs(true,dbop.getDataSource(), tableName, objects);
		else
			return null;
	} catch (Exception e) {
		if(e instanceof DataAccessException||e instanceof CannotGetJdbcConnectionException){
			 if(notify==null){
				 notify=MTSystemService.getInstance().getNotifyService();
			 }
			 notify.initData(null, e,SpringUtil.getApplicationContext().getApplicationName());
			 executor.execute(notify);
		 }
		e.printStackTrace();
		throw e;
	}
}
 
开发者ID:zhanggh,项目名称:mtools,代码行数:24,代码来源:CoreDao.java


示例8: update

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
public int update(Object obj) throws Exception{
	try {
		String tableName = DBUtil.getTableName(obj);
		if(tableName!=null)
			return DBUtil.updateObjFull(true,dbop, tableName, obj.getClass(), obj, DBUtil.getTableKeys(obj));
		else
			return 0;
	} catch (Exception e) {
		if(e instanceof DataAccessException||e instanceof CannotGetJdbcConnectionException){
			 if(notify==null){
				 notify=MTSystemService.getInstance().getNotifyService();
			 } 
			 notify.initData(null, e,SpringUtil.getApplicationContext().getApplicationName());
			 executor.execute(notify);
		 }
		e.printStackTrace();
		throw e;
	}
}
 
开发者ID:zhanggh,项目名称:mtools,代码行数:20,代码来源:CoreDao.java


示例9: delete

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
public int delete(Object obj) throws Exception{
	try {
		String tableName = DBUtil.getTableName(obj);
		if(tableName!=null)
			return DBUtil.deleteObj(true,dbop, tableName, obj, DBUtil.getTableKeys(obj));
		else
			return 0;
	} catch (Exception e) {
		if(e instanceof DataAccessException||e instanceof CannotGetJdbcConnectionException){
			 if(notify==null){
				 notify=MTSystemService.getInstance().getNotifyService();
			 } 
			 notify.initData(null, e,SpringUtil.getApplicationContext().getApplicationName());
			 executor.execute(notify);
		 }
		e.printStackTrace();
		throw e;
	}
}
 
开发者ID:zhanggh,项目名称:mtools,代码行数:20,代码来源:CoreDao.java


示例10: find

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
public <T> T find(Object obj,Class<T> clz) throws Exception{
	try {
		if(clz==null) clz=(Class<T>)obj.getClass();
		String tableName = DBUtil.getTableName(clz);
		if(tableName!=null)
			return clz.cast(DBUtil.findObj(true,dbop, tableName, obj, clz, DBUtil.getTableKeys(obj)));
		else
			return null;
	} catch (Exception e) {
		if(e instanceof DataAccessException||e instanceof CannotGetJdbcConnectionException){
			 if(notify==null){
				 notify=MTSystemService.getInstance().getNotifyService();
			 } 
			 notify.initData(null, e,SpringUtil.getApplicationContext().getApplicationName());
			 executor.execute(notify);
		 }
		e.printStackTrace();
		throw e;
	}
}
 
开发者ID:zhanggh,项目名称:mtools,代码行数:21,代码来源:CoreDao.java


示例11: findList

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
public <T> T findList(Class<T> clz,String tableName,String...args) throws Exception
{
	try {
		if(tableName==null) tableName = DBUtil.getTableName(clz);
		if(tableName!=null)
			return clz.cast(DBUtil.findList(dbop, tableName, clz, args));
		else
			return null;
	} catch (Exception e) {
		if(e instanceof DataAccessException||e instanceof CannotGetJdbcConnectionException){
			 if(notify==null){
				 notify=MTSystemService.getInstance().getNotifyService();
			 } 
			 notify.initData(null, e,SpringUtil.getApplicationContext().getApplicationName());
			 executor.execute(notify);
		 }
		e.printStackTrace();
		throw e;
	}
}
 
开发者ID:zhanggh,项目名称:mtools,代码行数:21,代码来源:CoreDao.java


示例12: executeWith

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
protected Object executeWith(Connection connection, SqlMapClientCallback action) {
    SqlMapSession session = getSqlMapClient().openSession();
    try {
        try {
            session.setUserConnection(connection);
        } catch (SQLException e) {
            throw new CannotGetJdbcConnectionException("Could not get JDBC Connection", e);
        }
        try {
            return action.doInSqlMapClient(session);
        } catch (SQLException ex) {
            throw new SQLErrorCodeSQLExceptionTranslator().translate("SqlMapClient operation",
                    null, ex);
        }
    } finally {
        session.close();
    }
}
 
开发者ID:alibaba,项目名称:cobarclient,代码行数:19,代码来源:DefaultConcurrentRequestProcessor.java


示例13: fetchConnectionsAndDepositForLaterUse

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
private List<RequestDepository> fetchConnectionsAndDepositForLaterUse(
                                                                      List<ConcurrentRequest> requests) {
    List<RequestDepository> depos = new ArrayList<RequestDepository>();
    for (ConcurrentRequest request : requests) {
        DataSource dataSource = request.getDataSource();

        Connection springCon = null;
        boolean transactionAware = (dataSource instanceof TransactionAwareDataSourceProxy);
        try {
            springCon = (transactionAware ? dataSource.getConnection() : DataSourceUtils
                    .doGetConnection(dataSource));
        } catch (SQLException ex) {
            throw new CannotGetJdbcConnectionException("Could not get JDBC Connection", ex);
        }

        RequestDepository depo = new RequestDepository();
        depo.setOriginalRequest(request);
        depo.setConnectionToUse(springCon);
        depo.setTransactionAware(transactionAware);
        depos.add(depo);
    }

    return depos;
}
 
开发者ID:alibaba,项目名称:cobarclient,代码行数:25,代码来源:DefaultConcurrentRequestProcessor.java


示例14: getConnection

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
public Connection getConnection() {
    if (dataSource == null) {
        throw new RuntimeException("dataSource is null  no bean dataSource please set spring xml ");
    }
    try {
        return DataSourceUtils.getConnection(dataSource);
    } catch (CannotGetJdbcConnectionException e) {
        try {
            return dataSource.getConnection();
        } catch (SQLException e1) {
            throw new JkException(e);
        }
    }
}
 
开发者ID:lftao,项目名称:jkami,代码行数:15,代码来源:RunConfing.java


示例15: linkInvalidDatabase

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
@Test(expected = CannotGetJdbcConnectionException.class)
public void linkInvalidDatabase() throws Exception {

	final Project project = new Project();
	project.setName("TEST");
	project.setPkey("test");
	project.setTeamLeader(getAuthenticationName());
	em.persist(project);

	final Subscription subscription = new Subscription();
	subscription.setProject(project);
	subscription.setNode(nodeRepository.findOneExpected(JiraBaseResource.KEY));
	em.persist(subscription);
	final ParameterValue parameterValueEntity = new ParameterValue();
	parameterValueEntity.setParameter(parameterRepository.findOne(JiraBaseResource.PARAMETER_JDBC_URL));
	parameterValueEntity.setData("jdbc:hsqldb:mem:dataSource");
	parameterValueEntity.setSubscription(subscription);
	em.persist(parameterValueEntity);
	final ParameterValue parameterValueEntity2 = new ParameterValue();
	parameterValueEntity2.setParameter(parameterRepository.findOneExpected(JiraBaseResource.PARAMETER_JDBC_DRIVER));
	parameterValueEntity2.setData("org.hsqldb.jdbc.JDBCDriver");
	parameterValueEntity2.setSubscription(subscription);
	em.persist(parameterValueEntity2);
	final ParameterValue parameterValueEntity3 = new ParameterValue();
	parameterValueEntity3.setParameter(parameterRepository.findOneExpected(JiraBaseResource.PARAMETER_JDBC_PASSSWORD));
	parameterValueEntity3.setData("invalid");
	parameterValueEntity3.setSubscription(subscription);
	em.persist(parameterValueEntity3);
	em.flush();
	em.clear();

	resource.link(subscription.getId());
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:34,代码来源:JiraPluginResourceTest.java


示例16: testCouldntGetConnectionForOperationOrExceptionTranslator

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
@Test
public void testCouldntGetConnectionForOperationOrExceptionTranslator() throws SQLException {
	SQLException sqlException = new SQLException("foo", "07xxx");
	this.dataSource = mock(DataSource.class);
	given(this.dataSource.getConnection()).willThrow(sqlException);
	JdbcTemplate template = new JdbcTemplate(this.dataSource, false);
	RowCountCallbackHandler rcch = new RowCountCallbackHandler();
	this.thrown.expect(CannotGetJdbcConnectionException.class);
	this.thrown.expect(exceptionCause(sameInstance(sqlException)));
	template.query("SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3", rcch);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:JdbcTemplateTests.java


示例17: testCouldntGetConnectionForOperationWithLazyExceptionTranslator

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
@Test
public void testCouldntGetConnectionForOperationWithLazyExceptionTranslator() throws SQLException {
	SQLException sqlException = new SQLException("foo", "07xxx");
	this.dataSource = mock(DataSource.class);
	given(this.dataSource.getConnection()).willThrow(sqlException);
	this.template = new JdbcTemplate();
	this.template.setDataSource(this.dataSource);
	this.template.afterPropertiesSet();
	RowCountCallbackHandler rcch = new RowCountCallbackHandler();
	this.thrown.expect(CannotGetJdbcConnectionException.class);
	this.thrown.expect(exceptionCause(sameInstance(sqlException)));
	this.template.query("SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3", rcch);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:JdbcTemplateTests.java


示例18: getConnection

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
public static Connection getConnection(DataSource dataSource) 
	throws CannotGetJdbcConnectionException, Exception {
	
	if (dataSource==null) {
		return null;
	}
	return DataSourceUtils.getConnection(dataSource);
}
 
开发者ID:billchen198318,项目名称:bamboobsc,代码行数:9,代码来源:DataUtils.java


示例19: checkConnection

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
@Override
public boolean checkConnection() {
    try {
        return null != getVersion();
    } catch (CannotGetJdbcConnectionException ex) {
        logger.error(new StringBuilder("checkConnection error for Url:").append(((DruidDataSource) this.getDataSource()).getUrl())
            .toString());
        return false;
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        return false;
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:14,代码来源:CobarAdapter.java


示例20: initPaginationSupport

import org.springframework.jdbc.CannotGetJdbcConnectionException; //导入依赖的package包/类
private void initPaginationSupport() {

		Connection conn = null;
		
		String databaseProductName = null;

		try {
			
			conn = getDataSource().getConnection();
					
			databaseProductName = conn.getMetaData().getDatabaseProductName().toUpperCase();
		} 
		catch (SQLException e) {
			
			throw new CannotGetJdbcConnectionException("�������ݿ�ʧ��", e);
		}
		finally {
			
			if(conn != null) {
				
				DataSourceUtils.releaseConnection(conn, getDataSource());
			}
		}

		if (databaseProductName.contains("ORACLE")) {
			
			this.paginationSupport = new OraclePaginationSupport();
		} 
		else if (databaseProductName.contains("MYSQL")
				|| databaseProductName.contains("MARIADB")) {
			
			this.paginationSupport = new MysqlPaginationSupport();
		} 
		else {
			
			throw new UnsupportedOperationException("�ݲ�֧�ֱ����ݿ�ķ�ҳ��������ʵ��com.nway.spring.jdbc.PaginationSupport�ӿڣ�ͨ������setPaginationSupport�������롣");
		}
	}
 
开发者ID:zdtjss,项目名称:nway-jdbc,代码行数:39,代码来源:SqlExecutor.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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