Search in sources :

Example 1 with DbAttachInfo

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

the class WireDatabaseConnection method toDbAttachInfo.

@Override
protected DbAttachInfo toDbAttachInfo(IConnectionProperties attachProperties) throws SQLException {
    final DbAttachInfo initialDbAttachInfo = DbAttachInfo.of(attachProperties);
    DbAttachInfo dbAttachInfo = initialDbAttachInfo.hasServerName() ? initialDbAttachInfo : DbAttachInfo.parseConnectString(initialDbAttachInfo.getAttachObjectName());
    if (!dbAttachInfo.hasServerName()) {
        // fallback to localhost (preserves backwards compatibility when serverName/host defaulted to localhost)
        dbAttachInfo = dbAttachInfo.withServerName(PropertyConstants.DEFAULT_SERVER_NAME);
    }
    if (!dbAttachInfo.hasAttachObjectName()) {
        throw new FbExceptionBuilder().nonTransientConnectionException(JaybirdErrorCodes.jb_invalidConnectionString).messageParameter(initialDbAttachInfo.getAttachObjectName()).messageParameter("null or empty database name in connection string").toFlatSQLException();
    }
    return dbAttachInfo;
}
Also used : DbAttachInfo(org.firebirdsql.gds.impl.DbAttachInfo) FbExceptionBuilder(org.firebirdsql.gds.ng.FbExceptionBuilder)

Example 2 with DbAttachInfo

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

the class WireServiceConnection method toDbAttachInfo.

@Override
protected DbAttachInfo toDbAttachInfo(IServiceProperties attachProperties) throws SQLException {
    final DbAttachInfo initialDbAttachInfo = DbAttachInfo.of(attachProperties);
    DbAttachInfo dbAttachInfo;
    if (initialDbAttachInfo.hasServerName()) {
        dbAttachInfo = initialDbAttachInfo;
    } else if (initialDbAttachInfo.hasAttachObjectName()) {
        dbAttachInfo = DbAttachInfo.parseConnectString(initialDbAttachInfo.getAttachObjectName());
    } else {
        // fallback to localhost + service_mgr
        return new DbAttachInfo(PropertyConstants.DEFAULT_SERVER_NAME, initialDbAttachInfo.getPortNumber(), PropertyConstants.DEFAULT_SERVICE_NAME);
    }
    if (!dbAttachInfo.hasServerName()) {
        // fallback to localhost (preserves backwards compatibility when serverName/host defaulted to localhost)
        dbAttachInfo = dbAttachInfo.withServerName(PropertyConstants.DEFAULT_SERVER_NAME);
    }
    if (!dbAttachInfo.hasAttachObjectName()) {
        // fallback to service_mgr
        dbAttachInfo = dbAttachInfo.withAttachObjectName(PropertyConstants.DEFAULT_SERVICE_NAME);
    }
    return dbAttachInfo;
}
Also used : DbAttachInfo(org.firebirdsql.gds.impl.DbAttachInfo)

Aggregations

DbAttachInfo (org.firebirdsql.gds.impl.DbAttachInfo)2 FbExceptionBuilder (org.firebirdsql.gds.ng.FbExceptionBuilder)1