Search in sources :

Example 6 with GDSType

use of org.firebirdsql.gds.impl.GDSType in project jaybird by FirebirdSQL.

the class FBTestProperties method defaultDatabaseSetUp.

/**
 * Creates the default test database, and configures the passed in FBManager with the server and type of test.
 *
 * @param fbManager instance used for creation of the database
 * @throws Exception
 */
public static void defaultDatabaseSetUp(FBManager fbManager) throws Exception {
    final GDSType gdsType = getGdsType();
    if (gdsType == GDSType.getType("PURE_JAVA") || gdsType == GDSType.getType("NATIVE") || gdsType == GDSType.getType("OOREMOTE")) {
        fbManager.setServer(DB_SERVER_URL);
        fbManager.setPort(DB_SERVER_PORT);
    }
    fbManager.start();
    fbManager.setForceCreate(true);
    // disable force write for minor increase in test throughput
    fbManager.setForceWrite(false);
    fbManager.createDatabase(getDatabasePath(), DB_USER, DB_PASSWORD);
}
Also used : GDSType(org.firebirdsql.gds.impl.GDSType)

Example 7 with GDSType

use of org.firebirdsql.gds.impl.GDSType in project jaybird by FirebirdSQL.

the class FBDriver method connect.

@Override
public Connection connect(String url, final Properties info) throws SQLException {
    if (url == null) {
        throw new SQLException("url is null");
    }
    final GDSType type = GDSFactory.getTypeForProtocol(url);
    if (type == null) {
        return null;
    }
    final Map<String, String> mergedProperties = mergeProperties(url, info);
    try {
        int qMarkIndex = url.indexOf('?');
        if (qMarkIndex != -1) {
            url = url.substring(0, qMarkIndex);
        }
        FBManagedConnectionFactory mcf = new FBManagedConnectionFactory(type);
        String databaseURL = GDSFactory.getDatabasePath(type, url);
        // NOTE: occurrence of an explicit connection property may override this
        mcf.setDatabaseName(databaseURL);
        for (Map.Entry<String, String> entry : mergedProperties.entrySet()) {
            try {
                mcf.setProperty(entry.getKey(), entry.getValue());
            } catch (InvalidPropertyValueException e) {
                throw e.asSQLException();
            }
        }
        FBTpbMapper.processMapping(mcf, mergedProperties);
        mcf = mcf.canonicalize();
        FBDataSource dataSource = createDataSource(mcf);
        return dataSource.getConnection(mcf.getUser(), mcf.getPassword());
    } catch (GDSException e) {
        throw new FBSQLException(e);
    }
}
Also used : FBManagedConnectionFactory(org.firebirdsql.jaybird.xca.FBManagedConnectionFactory) InvalidPropertyValueException(org.firebirdsql.jaybird.props.InvalidPropertyValueException) GDSException(org.firebirdsql.gds.GDSException) GDSType(org.firebirdsql.gds.impl.GDSType) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with GDSType

use of org.firebirdsql.gds.impl.GDSType in project jaybird by FirebirdSQL.

the class TestFBConnectionTimeout method buildTestURL.

/**
 * Builds the test URL (to a non-existent IP) for the current GDS testtype.
 *
 * @return Test URL to a non-existent IP
 */
private static String buildTestURL() {
    GDSType gdsType = FBTestProperties.getGdsType();
    FbConnectionProperties properties = new FbConnectionProperties();
    properties.setServerName(NON_EXISTENT_IP);
    properties.setDatabaseName("db");
    try {
        return GDSFactory.getJdbcUrl(gdsType, properties);
    } catch (SQLException e) {
        fail("Unable to generate testURL");
    }
    return null;
}
Also used : SQLException(java.sql.SQLException) FbConnectionProperties(org.firebirdsql.gds.ng.FbConnectionProperties) GDSType(org.firebirdsql.gds.impl.GDSType)

Example 9 with GDSType

use of org.firebirdsql.gds.impl.GDSType in project jaybird by FirebirdSQL.

the class FBConnectionPoolDataSource method initialize.

private void initialize() throws SQLException {
    synchronized (lock) {
        if (internalDs != null) {
            return;
        }
        GDSType gdsType = GDSType.getType(getType());
        if (gdsType == null) {
            gdsType = GDSFactory.getDefaultGDSType();
        }
        FBManagedConnectionFactory mcf = new FBManagedConnectionFactory(gdsType, getConnectionProperties());
        internalDs = (FBDataSource) mcf.createConnectionFactory();
        internalDs.setLogWriter(getLogWriter());
    }
}
Also used : FBManagedConnectionFactory(org.firebirdsql.jaybird.xca.FBManagedConnectionFactory) GDSType(org.firebirdsql.gds.impl.GDSType)

Aggregations

GDSType (org.firebirdsql.gds.impl.GDSType)9 FBManagedConnectionFactory (org.firebirdsql.jaybird.xca.FBManagedConnectionFactory)3 SQLException (java.sql.SQLException)2 File (java.io.File)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 GDSException (org.firebirdsql.gds.GDSException)1 FbConnectionProperties (org.firebirdsql.gds.ng.FbConnectionProperties)1 InvalidPropertyValueException (org.firebirdsql.jaybird.props.InvalidPropertyValueException)1 FBManager (org.firebirdsql.management.FBManager)1 FBServiceManager (org.firebirdsql.management.FBServiceManager)1