Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/activemq/store/jdbc/adapter/OracleJDBCAdapter.java


1   /**
2    * 
3    * Copyright 2004 Protique Ltd
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License"); 
6    * you may not use this file except in compliance with the License. 
7    * You may obtain a copy of the License at 
8    * 
9    * http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, 
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
14   * See the License for the specific language governing permissions and 
15   * limitations under the License. 
16   * 
17   **/
18  package org.activemq.store.jdbc.adapter;
19  
20  import java.sql.Blob;
21  import java.sql.ResultSet;
22  import java.sql.SQLException;
23  
24  import org.activemq.store.jdbc.StatementProvider;
25  
26  /**
27   * Implements all the default JDBC operations that are used
28   * by the JDBCPersistenceAdapter.
29   * <p/>
30   * Subclassing is encouraged to override the default
31   * implementation of methods to account for differences
32   * in JDBC Driver implementations.
33   * <p/>
34   * The JDBCAdapter inserts and extracts BLOB data using the
35   * getBytes()/setBytes() operations.
36   * <p/>
37   * The databases/JDBC drivers that use this adapter are:
38   * <ul>
39   * <li></li>
40   * </ul>
41   *
42   * @version $Revision: 1.1 $
43   */
44  public class OracleJDBCAdapter extends DefaultJDBCAdapter {
45  
46      public static StatementProvider createStatementProvider() {
47          DefaultStatementProvider answer = new DefaultStatementProvider();
48          answer.setLongDataType("NUMBER");
49          return answer;
50      }
51      
52      public OracleJDBCAdapter() {
53          this(createStatementProvider());
54      }
55  
56      public OracleJDBCAdapter(StatementProvider provider) {
57          super(provider);        
58      }
59      
60      protected byte[] getBinaryData(ResultSet rs, int index) throws SQLException {
61  
62          // Get as a BLOB
63          Blob aBlob = rs.getBlob(1);
64          return aBlob.getBytes(1, (int) aBlob.length());
65      }
66  }