001/* 002// This software is subject to the terms of the Eclipse Public License v1.0 003// Agreement, available at the following URL: 004// http://www.eclipse.org/legal/epl-v10.html. 005// You must accept the terms of that agreement to use this software. 006// 007// Copyright (C) 2007-2012 Pentaho 008// All Rights Reserved. 009*/ 010package mondrian.olap4j; 011 012import mondrian.rolap.RolapConnection; 013 014import org.olap4j.OlapException; 015 016import java.sql.*; 017import java.util.*; 018import java.util.concurrent.Executor; 019 020/** 021 * Implementation of {@link mondrian.olap4j.Factory} for JDBC 4.1. 022 * 023 * @author jhyde 024 */ 025class FactoryJdbc41Impl implements Factory { 026 public Connection newConnection( 027 MondrianOlap4jDriver driver, 028 String url, 029 Properties info) 030 throws SQLException 031 { 032 return new MondrianOlap4jConnectionJdbc41(this, driver, url, info); 033 } 034 035 public EmptyResultSet newEmptyResultSet( 036 MondrianOlap4jConnection olap4jConnection) 037 { 038 List<String> headerList = Collections.emptyList(); 039 List<List<Object>> rowList = Collections.emptyList(); 040 return new EmptyResultSetJdbc41( 041 olap4jConnection, headerList, rowList); 042 } 043 044 public ResultSet newFixedResultSet( 045 MondrianOlap4jConnection olap4jConnection, 046 List<String> headerList, 047 List<List<Object>> rowList) 048 { 049 return new EmptyResultSetJdbc41( 050 olap4jConnection, headerList, rowList); 051 } 052 053 public MondrianOlap4jCellSet newCellSet( 054 MondrianOlap4jStatement olap4jStatement) 055 { 056 return new MondrianOlap4jCellSetJdbc41(olap4jStatement); 057 } 058 059 public MondrianOlap4jStatement newStatement( 060 MondrianOlap4jConnection olap4jConnection) 061 { 062 return new MondrianOlap4jStatementJdbc41(olap4jConnection); 063 } 064 065 public MondrianOlap4jPreparedStatement newPreparedStatement( 066 String mdx, 067 MondrianOlap4jConnection olap4jConnection) 068 throws OlapException 069 { 070 return new MondrianOlap4jPreparedStatementJdbc41(olap4jConnection, mdx); 071 } 072 073 public MondrianOlap4jDatabaseMetaData newDatabaseMetaData( 074 MondrianOlap4jConnection olap4jConnection, 075 RolapConnection mondrianConnection) 076 { 077 return new MondrianOlap4jDatabaseMetaDataJdbc41( 078 olap4jConnection, mondrianConnection); 079 } 080 081 // Inner classes 082 083 private static class EmptyResultSetJdbc41 084 extends FactoryJdbc4Plus.AbstractEmptyResultSet 085 { 086 EmptyResultSetJdbc41( 087 MondrianOlap4jConnection olap4jConnection, 088 List<String> headerList, 089 List<List<Object>> rowList) 090 { 091 super(olap4jConnection, headerList, rowList); 092 } 093 094 public <T> T getObject( 095 int columnIndex, 096 Class<T> type) throws SQLException 097 { 098 throw new UnsupportedOperationException(); 099 } 100 101 public <T> T getObject( 102 String columnLabel, 103 Class<T> type) throws SQLException 104 { 105 throw new UnsupportedOperationException(); 106 } 107 } 108 109 private static class MondrianOlap4jConnectionJdbc41 110 extends FactoryJdbc4Plus.AbstractConnection 111 { 112 MondrianOlap4jConnectionJdbc41( 113 Factory factory, 114 MondrianOlap4jDriver driver, 115 String url, 116 Properties info) throws SQLException 117 { 118 super(factory, driver, url, info); 119 } 120 121 public void abort(Executor executor) throws SQLException { 122 throw new UnsupportedOperationException(); 123 } 124 125 public void setNetworkTimeout( 126 Executor executor, 127 int milliseconds) throws SQLException 128 { 129 throw new UnsupportedOperationException(); 130 } 131 132 public int getNetworkTimeout() throws SQLException 133 { 134 throw new UnsupportedOperationException(); 135 } 136 } 137 138 private static class MondrianOlap4jCellSetJdbc41 139 extends FactoryJdbc4Plus.AbstractCellSet 140 { 141 public MondrianOlap4jCellSetJdbc41( 142 MondrianOlap4jStatement olap4jStatement) 143 { 144 super(olap4jStatement); 145 } 146 147 public <T> T getObject( 148 int columnIndex, 149 Class<T> type) throws SQLException 150 { 151 throw new UnsupportedOperationException(); 152 } 153 154 public <T> T getObject( 155 String columnLabel, 156 Class<T> type) throws SQLException 157 { 158 throw new UnsupportedOperationException(); 159 } 160 } 161 162 private static class MondrianOlap4jStatementJdbc41 163 extends MondrianOlap4jStatement 164 { 165 public MondrianOlap4jStatementJdbc41( 166 MondrianOlap4jConnection olap4jConnection) 167 { 168 super(olap4jConnection); 169 } 170 171 public void closeOnCompletion() throws SQLException { 172 closeOnCompletion = true; 173 } 174 175 public boolean isCloseOnCompletion() throws SQLException { 176 return closeOnCompletion; 177 } 178 } 179 180 private static class MondrianOlap4jPreparedStatementJdbc41 181 extends FactoryJdbc4Plus.AbstractPreparedStatement 182 { 183 public MondrianOlap4jPreparedStatementJdbc41( 184 MondrianOlap4jConnection olap4jConnection, 185 String mdx) 186 throws OlapException 187 { 188 super(olap4jConnection, mdx); 189 } 190 191 public void closeOnCompletion() throws SQLException { 192 closeOnCompletion = true; 193 } 194 195 public boolean isCloseOnCompletion() throws SQLException { 196 return closeOnCompletion; 197 } 198 } 199 200 private static class MondrianOlap4jDatabaseMetaDataJdbc41 201 extends FactoryJdbc4Plus.AbstractDatabaseMetaData 202 { 203 public MondrianOlap4jDatabaseMetaDataJdbc41( 204 MondrianOlap4jConnection olap4jConnection, 205 RolapConnection mondrianConnection) 206 { 207 super(olap4jConnection, mondrianConnection); 208 } 209 210 public ResultSet getPseudoColumns( 211 String catalog, 212 String schemaPattern, 213 String tableNamePattern, 214 String columnNamePattern) throws SQLException 215 { 216 throw new UnsupportedOperationException(); 217 } 218 219 public boolean generatedKeyAlwaysReturned() throws SQLException { 220 throw new UnsupportedOperationException(); 221 } 222 } 223} 224 225// End FactoryJdbc41Impl.java