Search in sources :

Example 1 with SQLServerDialect

use of org.alfresco.repo.domain.dialect.SQLServerDialect in project alfresco-repository by Alfresco.

the class DataSourceCheck method init.

public void init() {
    logger.info(I18NUtil.getMessage(MSG_DB_CONNECTION, dbUrl, dbUsername));
    Connection con = null;
    try {
        con = dataSource.getConnection();
        con.setAutoCommit(true);
        DatabaseMetaData meta = con.getMetaData();
        logger.info(I18NUtil.getMessage(MSG_DB_VERSION, meta.getDatabaseProductName(), meta.getDatabaseProductVersion()));
        Dialect dialect = DialectFactory.buildDialect(meta.getDatabaseProductName(), meta.getDatabaseMajorVersion(), meta.getDriverName());
        // Check MS SQL Server specific settings
        if (dialect instanceof SQLServerDialect) {
            if (transactionIsolation != SQL_SERVER_TRANSACTION_ISOLATION) {
                throw new AlfrescoRuntimeException(ERR_WRONG_TRANSACTION_ISOLATION_SQL_SERVER, new Object[] { transactionIsolation, SQL_SERVER_TRANSACTION_ISOLATION });
            }
        }
    } catch (RuntimeException re) {
        // just rethrow
        throw re;
    } catch (Exception e) {
        throw new AlfrescoRuntimeException(ERR_DB_CONNECTION, new Object[] { e.getMessage() }, e);
    } finally {
        try {
            con.close();
        } catch (Exception e) {
        }
    }
}
Also used : SQLServerDialect(org.alfresco.repo.domain.dialect.SQLServerDialect) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) Connection(java.sql.Connection) Dialect(org.alfresco.repo.domain.dialect.Dialect) SQLServerDialect(org.alfresco.repo.domain.dialect.SQLServerDialect) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) DatabaseMetaData(java.sql.DatabaseMetaData) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException)

Example 2 with SQLServerDialect

use of org.alfresco.repo.domain.dialect.SQLServerDialect in project alfresco-repository by Alfresco.

the class SchemaBootstrap method checkDialect.

/**
 * Performs dialect-specific checking.  This includes checking for InnoDB, dumping the dialect being used
 * as well as setting any runtime, dialect-specific properties.
 */
private void checkDialect(Dialect dialect) {
    Class<?> dialectClazz = dialect.getClass();
    LogUtil.info(logger, MSG_DIALECT_USED, dialectClazz.getName());
    // if (dialectClazz.equals(MySQLDialect.class) || dialectClazz.equals(MySQL5Dialect.class))
    // {
    // LogUtil.error(logger, ERR_DIALECT_SHOULD_USE, dialectClazz.getName(), MySQLInnoDBDialect.class.getName());
    // throw AlfrescoRuntimeException.create(WARN_DIALECT_UNSUPPORTED, dialectClazz.getName());
    // }
    // else if (dialectClazz.equals(HSQLDialect.class))
    // {
    // LogUtil.info(logger, WARN_DIALECT_HSQL);
    // }
    // else if (dialectClazz.equals(DerbyDialect.class))
    // {
    // LogUtil.info(logger, WARN_DIALECT_DERBY);
    // }
    // else if (dialectClazz.equals(Oracle9iDialect.class) || dialectClazz.equals(Oracle10gDialect.class))
    // {
    // LogUtil.error(logger, ERR_DIALECT_SHOULD_USE, dialectClazz.getName(), Oracle9Dialect.class.getName());
    // throw AlfrescoRuntimeException.create(WARN_DIALECT_UNSUPPORTED, dialectClazz.getName());
    // }
    // else if (dialectClazz.equals(OracleDialect.class) || dialectClazz.equals(Oracle9Dialect.class))
    // {
    // LogUtil.error(logger, ERR_DIALECT_SHOULD_USE, dialectClazz.getName(), Oracle9Dialect.class.getName());
    // throw AlfrescoRuntimeException.create(WARN_DIALECT_UNSUPPORTED, dialectClazz.getName());
    // }
    int maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
    int serializableType = SerializableTypeHandler.getSerializableType();
    // Adjust the maximum allowable String length according to the dialect
    if (dialect instanceof SQLServerDialect) {
        // string_value nvarchar(1024) null,
        // serializable_value image null,
        maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
    } else if (dialect instanceof MySQLClusterNDBDialect) {
        // string_value varchar(400),
        // serializable_value blob,
        maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH_NDB;
    } else if (dialect instanceof MySQLInnoDBDialect) {
        // string_value text,
        // serializable_value blob,
        maxStringLength = Integer.MAX_VALUE;
    } else if (dialect instanceof Oracle9Dialect) {
        // string_value varchar2(1024 char),
        // serializable_value blob,
        maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
    } else if (dialect instanceof PostgreSQLDialect) {
        // string_value varchar(1024),
        // serializable_value bytea,
        maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
    }
    SchemaBootstrap.setMaxStringLength(maxStringLength, dialect);
    SerializableTypeHandler.setSerializableType(serializableType);
    // Now override the maximum string length if it was set directly
    if (maximumStringLength > 0) {
        SchemaBootstrap.setMaxStringLength(maximumStringLength, dialect);
    }
}
Also used : MySQLInnoDBDialect(org.alfresco.repo.domain.dialect.MySQLInnoDBDialect) PostgreSQLDialect(org.alfresco.repo.domain.dialect.PostgreSQLDialect) SQLServerDialect(org.alfresco.repo.domain.dialect.SQLServerDialect) MySQLClusterNDBDialect(org.alfresco.repo.domain.dialect.MySQLClusterNDBDialect) Oracle9Dialect(org.alfresco.repo.domain.dialect.Oracle9Dialect) Savepoint(java.sql.Savepoint)

Example 3 with SQLServerDialect

use of org.alfresco.repo.domain.dialect.SQLServerDialect in project alfresco-repository by Alfresco.

the class TypeNameOnlyValidatorTest method setUp.

@Before
public void setUp() throws Exception {
    validator = new TypeNameOnlyValidator();
    validationResults = new Results();
    ctx = new DiffContext(new SQLServerDialect(), validationResults, null, null);
}
Also used : DiffContext(org.alfresco.util.schemacomp.DiffContext) SQLServerDialect(org.alfresco.repo.domain.dialect.SQLServerDialect) Results(org.alfresco.util.schemacomp.Results) Before(org.junit.Before)

Aggregations

SQLServerDialect (org.alfresco.repo.domain.dialect.SQLServerDialect)3 Connection (java.sql.Connection)1 DatabaseMetaData (java.sql.DatabaseMetaData)1 Savepoint (java.sql.Savepoint)1 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)1 Dialect (org.alfresco.repo.domain.dialect.Dialect)1 MySQLClusterNDBDialect (org.alfresco.repo.domain.dialect.MySQLClusterNDBDialect)1 MySQLInnoDBDialect (org.alfresco.repo.domain.dialect.MySQLInnoDBDialect)1 Oracle9Dialect (org.alfresco.repo.domain.dialect.Oracle9Dialect)1 PostgreSQLDialect (org.alfresco.repo.domain.dialect.PostgreSQLDialect)1 DiffContext (org.alfresco.util.schemacomp.DiffContext)1 Results (org.alfresco.util.schemacomp.Results)1 Before (org.junit.Before)1