use of org.firebirdsql.jaybird.props.InvalidPropertyValueException 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);
}
}
Aggregations