/*
* $Header: /home/cvs/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/SQLServerRDBMSAdapter.java,v 1.2.2.1 2004/02/05 16:07:53 mholz Exp $
* $Revision: 1.2.2.1 $
* $Date: 2004/02/05 16:07:53 $
*
* ====================================================================
*
* Copyright 1999-2003 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.slide.store.impl.rdbms;
import java.sql.SQLException;
import org.apache.slide.common.*;
import org.apache.slide.macro.ConflictException;
import org.apache.slide.util.logger.Logger;
/**
* Adapter for MS SQLServer. Actually does not change a thing from StandardRDBMSAdapter.
*
* @author <a href="mailto:ozeigermann@c1-fse.de">Oliver Zeigermann</a>
* @version $Revision: 1.2.2.1 $
*/
public class SQLServerRDBMSAdapter extends StandardRDBMSAdapter {
protected static final String LOG_CHANNEL = SQLServerRDBMSAdapter.class.getName();
public SQLServerRDBMSAdapter(Service service, Logger logger) {
super(service, logger);
}
protected ServiceAccessException createException(SQLException e, String uri) {
switch (e.getErrorCode()) {
case 1205 : // thread was deadlock victim
getLogger().log(e.getErrorCode() + ": Deadlock resolved on " + uri, LOG_CHANNEL, Logger.WARNING);
return new ServiceAccessException(service, new ConflictException(uri));
case 547 : // referential integraty constaint was violated (like in storeObject on table URI )
case 2627 : // primary key constraint violation (like in storeContent on table VERSION_CONTENT)
getLogger().log(e.getErrorCode() + ": Low isolation conflict for " + uri, LOG_CHANNEL, Logger.WARNING);
return new ServiceAccessException(service, new ConflictException(uri));
default :
getLogger().log("SQL error " + e.getErrorCode() + " on " + uri + ": " + e.getMessage(),
LOG_CHANNEL,
Logger.ERROR);
return new ServiceAccessException(service, e);
}
}
}