Create XA connection from normal connection.

@param databaseType database type
@param connection normal connection
@param xaDataSource XA data source
@return XA connection
496164
public static XAConnection createXAConnection(final DatabaseType databaseType, final XADataSource xaDataSource, final Connection connection) {
        switch (databaseType) {
            case MySQL:
                return new MySQLXAConnectionWrapper().wrap(xaDataSource, connection);
            case PostgreSQL:
                return new PostgreSQLXAConnectionWrapper().wrap(xaDataSource, connection);
            case H2:
                return new H2XAConnectionWrapper().wrap(xaDataSource, connection);
            default:
                throw new UnsupportedOperationException(String.format("Cannot support database type: `%s`", databaseType));
        }
    }
1149916
public static XmlSqlInfoBuilder newInstace(BuildSource source) {
        XmlSqlInfoBuilder builder = new XmlSqlInfoBuilder();
        builder.init(source);
        return builder;
    }
970901
public static XAProperties createXAProperties(final DatabaseType databaseType) {
        switch (databaseType) {
            case H2:
                return new H2XAProperties();
            case MySQL:
                return new MySQLXAProperties();
            case PostgreSQL:
                return new PostgreSQLXAProperties();
            case Oracle:
                return new OracleXAProperties();
            case SQLServer:
                return new SQLServerXAProperties();
            default:
                throw new UnsupportedOperationException(String.format("Cannot support database type: `%s`", databaseType));
        }
    }
91053
public final Connection getConnection(final String dataSourceName) throws SQLException {
        return getConnections(ConnectionMode.MEMORY_STRICTLY, dataSourceName, 1).get(0);
    }
447481
public static <T, ID> RuntimeExceptionDao<T, ID> createDao(ConnectionSource connectionSource, Class<T> clazz)
			throws SQLException {
		@SuppressWarnings("unchecked")
		Dao<T, ID> castDao = (Dao<T, ID>) DaoManager.createDao(connectionSource, clazz);
		return new RuntimeExceptionDao<T, ID>(castDao);
	}
1224763
public static DatabaseProtocolFrontendEngine newInstance(final DatabaseType databaseType) {
        for (DatabaseProtocolFrontendEngine each : NewInstanceServiceLoader.newServiceInstances(DatabaseProtocolFrontendEngine.class)) {
            if (DatabaseType.valueFrom(each.getDatabaseType()) == databaseType) {
                return each;
            }
        }
        throw new UnsupportedOperationException(String.format("Cannot support database type '%s'", databaseType));
    }
1079472
public GenericConnectionFactory cloneWith(DataSource datasource)
   {
      try
      {
         GenericConnectionFactory factory = (GenericConnectionFactory)this.clone();
         factory.dbDataSource = datasource;
         return factory;
      }
      catch (CloneNotSupportedException e)
      {
         throw new AssertionError(); // Cannot occur
      }
   }
91722
public static <T> DatabaseTableConfig<T> fromClass(DatabaseType databaseType, Class<T> clazz) throws SQLException {
		String tableName = extractTableName(databaseType, clazz);
		if (databaseType.isEntityNamesMustBeUpCase()) {
			tableName = databaseType.upCaseEntityName(tableName);
		}
		return new DatabaseTableConfig<T>(databaseType, clazz, tableName,
				extractFieldTypes(databaseType, clazz, tableName));
	}
422393
public BaseDatabase makeDatabase(int iDatabaseType)
    {
        BaseDatabase database = null;
        String strDbPrefix = this.getDatabasePrefix(iDatabaseType);

        if (strDbPrefix != null) if (strDbPrefix.indexOf('.') == -1)
            strDbPrefix = DBConstants.ROOT_PACKAGE + "base.db." + strDbPrefix.toLowerCase() + "." + strDbPrefix + "Database";
        database = (BaseDatabase)ClassServiceUtility.getClassService().makeObjectFromClassName(strDbPrefix);
        if (database == null)
            database = new BaseDatabase();  // default
        return database;
    }
306536
public DatabaseConnectionRequest<T, U> setConnection(String connection) {
        request.addParameter(ParameterBuilder.CONNECTION_KEY, connection);
        return this;
    }
447245
protected function createDatabaseSchema(Connection $connection, DatabaseSchemaInterface $schema): void
    {
        try {
            $this->createDatabaseTables($connection, $schema);
            $this->createDatabaseViews($connection, $schema);
        } catch (DBALException $exception) {
            if ($connection->isConnected() === true) {
                $this->removeDatabaseSchema($connection, $schema);
            }

            throw $exception;
        }
    }
924591
private DBConn createAndConnectConn(String keyspace) throws DBNotAvailableException, RuntimeException {
        DBConn dbConn = new DBConn(this, keyspace);
        connectDBConn(dbConn);
        return dbConn;
    }
725396
public static AbstractSelectParser newInstance(final DatabaseType dbType, final ShardingRule shardingRule, final LexerEngine lexerEngine, final ShardingTableMetaData shardingTableMetaData) {
        switch (dbType) {
            case H2:
            case MySQL:
                return new MySQLSelectParser(shardingRule, lexerEngine, shardingTableMetaData);
            case Oracle:
                return new OracleSelectParser(shardingRule, lexerEngine, shardingTableMetaData);
            case SQLServer:
                return new SQLServerSelectParser(shardingRule, lexerEngine, shardingTableMetaData);
            case PostgreSQL:
                return new PostgreSQLSelectParser(shardingRule, lexerEngine, shardingTableMetaData);
            default:
                throw new UnsupportedOperationException(String.format("Cannot support database [%s].", dbType));
        }
    }
1246546
public void switchDataSource(BoneCPConfig newConfig) throws SQLException {
		logger.info("Switch to new datasource requested. New Config: "+newConfig);
		DataSource oldDS = getTargetDataSource();
 
		if (!(oldDS instanceof BoneCPDataSource)){
			throw new SQLException("Unknown datasource type! Was expecting BoneCPDataSource but received "+oldDS.getClass()+". Not switching datasource!");
		}
		
		BoneCPDataSource newDS = new BoneCPDataSource(newConfig);
		newDS.getConnection().close(); // initialize a connection (+ throw it away) to force the datasource to initialize the pool
		
		// force application to start using the new one 
		setTargetDataSource(newDS);
		
		logger.info("Shutting down old datasource slowly. Old Config: "+oldDS);
		// tell the old datasource to terminate. This terminates the pool lazily so existing checked out connections can still be used.
		((BoneCPDataSource)oldDS).close();
	}
830983
public static MariaDbConnection newConnection(UrlParser urlParser, GlobalStateInfo globalInfo)
      throws SQLException {
    if (urlParser.getOptions().pool) {
      return Pools.retrievePool(urlParser).getConnection();
    }

    Protocol protocol = Utils.retrieveProxy(urlParser, globalInfo);
    return new MariaDbConnection(protocol);
  }
308503
public static DataSource createDataSource(Properties poolProperties) throws SQLException {
        try {
            return MidaoFrameworkPoolBinder.createDataSource(poolProperties);
        } catch (NoClassDefFoundError ex) {
            throw new NoClassDefFoundError(ERROR_COULDNT_FIND_POOL_PROVIDER);
        }
    }
531038
public static DatabaseType createDatabaseType(String databaseUrl) {
		String dbTypePart = extractDbType(databaseUrl);
		for (DatabaseType databaseType : databaseTypes) {
			if (databaseType.isDatabaseUrlThisType(databaseUrl, dbTypePart)) {
				return databaseType;
			}
		}
		throw new IllegalArgumentException("Unknown database-type url part '" + dbTypePart + "' in: " + databaseUrl);
	}