Package org.apache.slide.store.impl.rdbms

Source Code of org.apache.slide.store.impl.rdbms.MySqlRDBMSAdapter

/*
* $Header: /home/cvs/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/MySqlRDBMSAdapter.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 MySQL 4.
*
* @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
* @version $Revision: 1.2.2.1 $
*/

public class MySqlRDBMSAdapter extends StandardRDBMSAdapter {

    protected static final String LOG_CHANNEL = MySqlRDBMSAdapter.class.getName();

    public MySqlRDBMSAdapter(Service service, Logger logger) {
        super(service, logger);
    }

    protected ServiceAccessException createException(SQLException e, String uri) {

        switch (e.getErrorCode()) {
            case 1213 : // thread was deadlock victim
                getLogger().log(e.getErrorCode() + ": Deadlock resolved on " + 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);
        }
    }

}
TOP

Related Classes of org.apache.slide.store.impl.rdbms.MySqlRDBMSAdapter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.