001 /** 002 * 003 * Copyright 2004 Protique Ltd 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 * 017 **/ 018 package org.activemq.store.jdbc.adapter; 019 020 import java.sql.Blob; 021 import java.sql.ResultSet; 022 import java.sql.SQLException; 023 024 import org.activemq.store.jdbc.StatementProvider; 025 026 /** 027 * Implements all the default JDBC operations that are used 028 * by the JDBCPersistenceAdapter. 029 * <p/> 030 * Subclassing is encouraged to override the default 031 * implementation of methods to account for differences 032 * in JDBC Driver implementations. 033 * <p/> 034 * The JDBCAdapter inserts and extracts BLOB data using the 035 * getBytes()/setBytes() operations. 036 * <p/> 037 * The databases/JDBC drivers that use this adapter are: 038 * <ul> 039 * <li></li> 040 * </ul> 041 * 042 * @version $Revision: 1.1 $ 043 */ 044 public class OracleJDBCAdapter extends DefaultJDBCAdapter { 045 046 public static StatementProvider createStatementProvider() { 047 DefaultStatementProvider answer = new DefaultStatementProvider(); 048 answer.setLongDataType("NUMBER"); 049 return answer; 050 } 051 052 public OracleJDBCAdapter() { 053 this(createStatementProvider()); 054 } 055 056 public OracleJDBCAdapter(StatementProvider provider) { 057 super(provider); 058 } 059 060 protected byte[] getBinaryData(ResultSet rs, int index) throws SQLException { 061 062 // Get as a BLOB 063 Blob aBlob = rs.getBlob(1); 064 return aBlob.getBytes(1, (int) aBlob.length()); 065 } 066 }