⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oracleblobjbossimpl.java

📁 CRM源码This file describes some issues that should be implemented in future and how it should be imple
💻 JAVA
字号:
/*
 * Copyright 2006-2007 Queplix Corp.
 *
 * Licensed under the Queplix Public License, Version 1.1.1 (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.queplix.com/solutions/commercial-open-source/queplix-public-license/
 *
 * 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 com.queplix.core.utils.sql.vendor.jboss;

import java.io.*;
import java.sql.*;

import com.queplix.core.error.*;
import oracle.jdbc.driver.*;
import oracle.sql.*;
import org.jboss.resource.adapter.jdbc.*;
import com.queplix.core.utils.sql.vendor.oracle.OracleBlob;

/**
 * This is a convenience class meant to generalize the action of updating an
 * BLOB column in an Oracle database.
 * This is JBOSS implementation. It checks SQL connection/statement/resultset
 * class if it's wrappeed and takes underlying object.
 * @author [ALB] Baranov Andrey
 * @see OracleBlob
 * @version $Revision: 1.1 $ $Date: 2005/03/04 10:45:27 $
 */
public class OracleBlobJBOSSImpl
    extends OracleBlob {

    // ========================================================== Public methods

    /*
     * No javadoc
     * @see OracleBlob#setObject
     */
    public void setObject( PreparedStatement stat, int pos, byte[] data ) {

        if( stat instanceof WrappedPreparedStatement ) {
            //stat = ( PreparedStatement ) ( ( WrappedPreparedStatement ) stat ).getUnderlyingStatement();
            try {
                stat = ( PreparedStatement ) ( ( WrappedPreparedStatement ) stat ).getUnderlyingStatement();
            } catch (SQLException e) {
                throw new GenericSystemException( "SQL exception: " + e.getMessage(), e );
            }
        }
        if( ! ( stat instanceof oracle.jdbc.driver.OraclePreparedStatement ) ) {
            throw new IllegalStateException( "Unexpected PreparedStatement class: " + stat.getClass() );
        }

        super.setObject( stat, pos, data );
    }

    /*
     * No javadoc
     * @see OracleBlob#getObject
     */
    public byte[] getObject( ResultSet rs, int pos ) {

        if( rs instanceof WrappedResultSet ) {
            try {
                rs = ( ( WrappedResultSet ) rs ).getUnderlyingResultSet();
            } catch( SQLException ex ) {
                throw new GenericSystemException( "SQL exception: " + ex.getMessage(), ex );
            }
        }

        if( ! ( rs instanceof OracleResultSet ) ) {
            throw new IllegalStateException( "Unexpected ResultSet class: " + rs.getClass() );
        }

        return super.getObject( rs, pos );
    }

    /*
     * No javadoc
     * @see OracleBlob#getObject
     */
    public byte[] getObject( CallableStatement cs, int pos ) {

        if( cs instanceof WrappedCallableStatement ) {
            try {
                cs = ( CallableStatement ) ( ( WrappedCallableStatement ) cs ).getUnderlyingStatement();
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        if( ! ( cs instanceof OracleCallableStatement ) ) {
            throw new IllegalStateException( "Unexpected CallableStatement class: " + cs.getClass() );
        }

        return super.getObject( cs, pos );
    }

    // ========================================================= Protected methods

    /*
     * No javadoc
     * @see OracleBlob#createBLOB
     */
    protected BLOB createBLOB( Connection conn, byte[] data ) {

        if( conn instanceof WrappedConnection ) {
            try {
                conn = ( ( WrappedConnection ) conn ).getUnderlyingConnection();
            } catch( SQLException ex ) {
                throw new GenericSystemException( "SQL exception: " + ex.getMessage(), ex );
            }
        }
        if( ! ( conn instanceof OracleConnection ) ) {
            throw new IllegalStateException( "Unexpected Connection class: " + conn.getClass() );
        }

        return super.createBLOB( conn, data );
    }

    /*
     * No javadoc
     * @see OracleBlob#freeBLOB
     */
    protected void freeBLOB( Connection conn, BLOB blob ) {

        if( conn instanceof WrappedConnection ) {
            try {
                conn = ( ( WrappedConnection ) conn ).getUnderlyingConnection();
            } catch( SQLException ex ) {
                throw new GenericSystemException( "SQL exception: " + ex.getMessage(), ex );
            }
        }
        if( ! ( conn instanceof OracleConnection ) ) {
            throw new IllegalStateException( "Unexpected Connection class: " + conn.getClass() );
        }

        super.freeBLOB( conn, blob );
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -