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);
}
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);
}
}
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;
}
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());
}
}
Aggregations