public Connection getDefaultConnection(String dbName, boolean isWrite) throws SQLException {
        if (dbName == null) {
            throw new DaoException("get connection error cause dbName id null");
        }
		Integer id = AppDBContext.getLastReadWriteFlag();
		// 写操作直接获得connection ,如果上一次操作是写连接，那么优先返回写连接
		if ( isWrite || (id != null && id < 0)) {
			AppDBContext.setLastReadWriteFlag(-1);
            IDataSourceProvider provider = DataSourceContext.getMasterDataSourceProvider(dbName);
            if (provider == null) {
                throw new DaoException("no write database dbName is " + dbName);
            }
            return provider.getDataSource().getConnection();
        } else {
			// 读操作取模做balance 负载均衡
            List<IDataSourceProvider> providers = DataSourceContext.getSlaveDataSourceProvider(dbName);
            if (providers == null || providers.size() == 0) {
                throw new DaoException("no slave database for clientId " + dbName);
            }
            int psize = providers.size();
			if (id == null) {
				id = Math.abs(concount++ % psize);
				AppDBContext.setLastReadWriteFlag(id);
			}
			IDataSourceProvider sdp = providers.get(id % psize);
            return sdp.getDataSource().getConnection();
        }
    }