001    /*
002    // $Id: //open/mondrian/src/main/mondrian/olap4j/FactoryJdbc4Impl.java#2 $
003    // This software is subject to the terms of the Common Public License
004    // Agreement, available at the following URL:
005    // http://www.opensource.org/licenses/cpl.html.
006    // Copyright (C) 2007-2007 Julian Hyde
007    // All Rights Reserved.
008    // You must accept the terms of that agreement to use this software.
009    */
010    package mondrian.olap4j;
011    
012    import org.olap4j.OlapConnection;
013    import org.olap4j.OlapStatement;
014    import org.olap4j.CellSetMetaData;
015    import org.olap4j.OlapDatabaseMetaData;
016    
017    import java.sql.*;
018    import java.util.*;
019    import java.io.Reader;
020    import java.io.InputStream;
021    
022    import mondrian.olap.Query;
023    
024    /**
025     * Implementation of {@link Factory} for JDBC 4.0.
026     *
027     * @author jhyde
028     * @version $Id: //open/mondrian/src/main/mondrian/olap4j/FactoryJdbc4Impl.java#2 $
029     * @since Jun 14, 2007
030     */
031    class FactoryJdbc4Impl implements Factory {
032        public Connection newConnection(
033            String url,
034            Properties info)
035            throws SQLException
036        {
037            return new MondrianOlap4jConnectionJdbc4(this, url, info);
038        }
039    
040        public EmptyResultSet newEmptyResultSet(
041            MondrianOlap4jConnection olap4jConnection)
042        {
043            List<String> headerList = Collections.emptyList();
044            List<List<Object>> rowList = Collections.emptyList();
045            return new EmptyResultSetJdbc4(
046                olap4jConnection, headerList, rowList);
047        }
048    
049        public ResultSet newFixedResultSet(
050            MondrianOlap4jConnection olap4jConnection,
051            List<String> headerList,
052            List<List<Object>> rowList)
053        {
054            return new EmptyResultSetJdbc4(
055                olap4jConnection, headerList, rowList);
056        }
057    
058        public MondrianOlap4jCellSet newCellSet(
059            MondrianOlap4jStatement olap4jStatement,
060            Query query)
061        {
062            return new MondrianOlap4jCellSetJdbc4(olap4jStatement, query);
063        }
064    
065        public MondrianOlap4jPreparedStatement newPreparedStatement(
066            String mdx,
067            MondrianOlap4jConnection olap4jConnection)
068        {
069            return new MondrianOlap4jPreparedStatementJdbc4(olap4jConnection, mdx);
070        }
071    
072        public MondrianOlap4jDatabaseMetaData newDatabaseMetaData(
073            MondrianOlap4jConnection olap4jConnection)
074        {
075            return new MondrianOlap4jDatabaseMetaDataJdbc4(olap4jConnection);
076        }
077    
078        // Inner classes
079    
080        private static class EmptyResultSetJdbc4 extends EmptyResultSet {
081            EmptyResultSetJdbc4(
082                MondrianOlap4jConnection olap4jConnection,
083                List<String> headerList,
084                List<List<Object>> rowList)
085            {
086                super(olap4jConnection, headerList, rowList);
087            }
088    
089            // implement java.sql.ResultSet methods
090            // introduced in JDBC 4.0/JDK 1.6
091    
092            public RowId getRowId(int columnIndex) throws SQLException {
093                throw new UnsupportedOperationException();
094            }
095    
096            public RowId getRowId(String columnLabel) throws SQLException {
097                throw new UnsupportedOperationException();
098            }
099    
100            public void updateRowId(int columnIndex, RowId x) throws SQLException {
101                throw new UnsupportedOperationException();
102            }
103    
104            public void updateRowId(String columnLabel, RowId x) throws SQLException {
105                throw new UnsupportedOperationException();
106            }
107    
108            public int getHoldability() throws SQLException {
109                throw new UnsupportedOperationException();
110            }
111    
112            public boolean isClosed() throws SQLException {
113                throw new UnsupportedOperationException();
114            }
115    
116            public void updateNString(
117                int columnIndex, String nString) throws SQLException {
118                throw new UnsupportedOperationException();
119            }
120    
121            public void updateNString(
122                String columnLabel, String nString) throws SQLException {
123                throw new UnsupportedOperationException();
124            }
125    
126            public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
127                throw new UnsupportedOperationException();
128            }
129    
130            public void updateNClob(
131                String columnLabel, NClob nClob) throws SQLException {
132                throw new UnsupportedOperationException();
133            }
134    
135            public NClob getNClob(int columnIndex) throws SQLException {
136                throw new UnsupportedOperationException();
137            }
138    
139            public NClob getNClob(String columnLabel) throws SQLException {
140                throw new UnsupportedOperationException();
141            }
142    
143            public SQLXML getSQLXML(int columnIndex) throws SQLException {
144                throw new UnsupportedOperationException();
145            }
146    
147            public SQLXML getSQLXML(String columnLabel) throws SQLException {
148                throw new UnsupportedOperationException();
149            }
150    
151            public void updateSQLXML(
152                int columnIndex, SQLXML xmlObject) throws SQLException {
153                throw new UnsupportedOperationException();
154            }
155    
156            public void updateSQLXML(
157                String columnLabel, SQLXML xmlObject) throws SQLException {
158                throw new UnsupportedOperationException();
159            }
160    
161            public String getNString(int columnIndex) throws SQLException {
162                throw new UnsupportedOperationException();
163            }
164    
165            public String getNString(String columnLabel) throws SQLException {
166                throw new UnsupportedOperationException();
167            }
168    
169            public Reader getNCharacterStream(int columnIndex) throws SQLException {
170                throw new UnsupportedOperationException();
171            }
172    
173            public Reader getNCharacterStream(String columnLabel) throws SQLException {
174                throw new UnsupportedOperationException();
175            }
176    
177            public void updateNCharacterStream(
178                int columnIndex, Reader x, long length) throws SQLException {
179                throw new UnsupportedOperationException();
180            }
181    
182            public void updateNCharacterStream(
183                String columnLabel, Reader reader, long length) throws SQLException {
184                throw new UnsupportedOperationException();
185            }
186    
187            public void updateAsciiStream(
188                int columnIndex, InputStream x, long length) throws SQLException {
189                throw new UnsupportedOperationException();
190            }
191    
192            public void updateBinaryStream(
193                int columnIndex, InputStream x, long length) throws SQLException {
194                throw new UnsupportedOperationException();
195            }
196    
197            public void updateCharacterStream(
198                int columnIndex, Reader x, long length) throws SQLException {
199                throw new UnsupportedOperationException();
200            }
201    
202            public void updateAsciiStream(
203                String columnLabel, InputStream x, long length) throws SQLException {
204                throw new UnsupportedOperationException();
205            }
206    
207            public void updateBinaryStream(
208                String columnLabel, InputStream x, long length) throws SQLException {
209                throw new UnsupportedOperationException();
210            }
211    
212            public void updateCharacterStream(
213                String columnLabel, Reader reader, long length) throws SQLException {
214                throw new UnsupportedOperationException();
215            }
216    
217            public void updateBlob(
218                int columnIndex,
219                InputStream inputStream,
220                long length) throws SQLException {
221                throw new UnsupportedOperationException();
222            }
223    
224            public void updateBlob(
225                String columnLabel,
226                InputStream inputStream,
227                long length) throws SQLException {
228                throw new UnsupportedOperationException();
229            }
230    
231            public void updateClob(
232                int columnIndex, Reader reader, long length) throws SQLException {
233                throw new UnsupportedOperationException();
234            }
235    
236            public void updateClob(
237                String columnLabel, Reader reader, long length) throws SQLException {
238                throw new UnsupportedOperationException();
239            }
240    
241            public void updateNClob(
242                int columnIndex, Reader reader, long length) throws SQLException {
243                throw new UnsupportedOperationException();
244            }
245    
246            public void updateNClob(
247                String columnLabel, Reader reader, long length) throws SQLException {
248                throw new UnsupportedOperationException();
249            }
250    
251            public void updateNCharacterStream(
252                int columnIndex, Reader x) throws SQLException {
253                throw new UnsupportedOperationException();
254            }
255    
256            public void updateNCharacterStream(
257                String columnLabel, Reader reader) throws SQLException {
258                throw new UnsupportedOperationException();
259            }
260    
261            public void updateAsciiStream(
262                int columnIndex, InputStream x) throws SQLException {
263                throw new UnsupportedOperationException();
264            }
265    
266            public void updateBinaryStream(
267                int columnIndex, InputStream x) throws SQLException {
268                throw new UnsupportedOperationException();
269            }
270    
271            public void updateCharacterStream(
272                int columnIndex, Reader x) throws SQLException {
273                throw new UnsupportedOperationException();
274            }
275    
276            public void updateAsciiStream(
277                String columnLabel, InputStream x) throws SQLException {
278                throw new UnsupportedOperationException();
279            }
280    
281            public void updateBinaryStream(
282                String columnLabel, InputStream x) throws SQLException {
283                throw new UnsupportedOperationException();
284            }
285    
286            public void updateCharacterStream(
287                String columnLabel, Reader reader) throws SQLException {
288                throw new UnsupportedOperationException();
289            }
290    
291            public void updateBlob(
292                int columnIndex, InputStream inputStream) throws SQLException {
293                throw new UnsupportedOperationException();
294            }
295    
296            public void updateBlob(
297                String columnLabel, InputStream inputStream) throws SQLException {
298                throw new UnsupportedOperationException();
299            }
300    
301            public void updateClob(int columnIndex, Reader reader) throws SQLException {
302                throw new UnsupportedOperationException();
303            }
304    
305            public void updateClob(
306                String columnLabel, Reader reader) throws SQLException {
307                throw new UnsupportedOperationException();
308            }
309    
310            public void updateNClob(
311                int columnIndex, Reader reader) throws SQLException {
312                throw new UnsupportedOperationException();
313            }
314    
315            public void updateNClob(
316                String columnLabel, Reader reader) throws SQLException {
317                throw new UnsupportedOperationException();
318            }
319        }
320    
321        private static class MondrianOlap4jConnectionJdbc4
322            extends MondrianOlap4jConnection
323            implements OlapConnection
324        {
325            MondrianOlap4jConnectionJdbc4(
326                Factory factory,
327                String url,
328                Properties info) throws SQLException
329            {
330                super(factory, url, info);
331            }
332    
333            public OlapStatement createStatement() {
334                return super.createStatement();
335            }
336    
337            public OlapDatabaseMetaData getMetaData() {
338                return super.getMetaData();
339            }
340    
341            // implement java.sql.Connection methods
342            // introduced in JDBC 4.0/JDK 1.6
343    
344            public Clob createClob() throws SQLException {
345                throw new UnsupportedOperationException();
346            }
347    
348            public Blob createBlob() throws SQLException {
349                throw new UnsupportedOperationException();
350            }
351    
352            public NClob createNClob() throws SQLException {
353                throw new UnsupportedOperationException();
354            }
355    
356            public SQLXML createSQLXML() throws SQLException {
357                throw new UnsupportedOperationException();
358            }
359    
360            public boolean isValid(int timeout) throws SQLException {
361                return !isClosed();
362            }
363    
364            public void setClientInfo(
365                String name, String value) throws SQLClientInfoException {
366                throw new UnsupportedOperationException();
367            }
368    
369            public void setClientInfo(Properties properties) throws SQLClientInfoException {
370                throw new UnsupportedOperationException();
371            }
372    
373            public String getClientInfo(String name) throws SQLException {
374                throw new UnsupportedOperationException();
375            }
376    
377            public Properties getClientInfo() throws SQLException {
378                throw new UnsupportedOperationException();
379            }
380    
381            public Array createArrayOf(
382                String typeName, Object[] elements) throws SQLException {
383                throw new UnsupportedOperationException();
384            }
385    
386            public Struct createStruct(
387                String typeName, Object[] attributes) throws SQLException {
388                throw new UnsupportedOperationException();
389            }
390        }
391    
392        private static class MondrianOlap4jCellSetJdbc4
393            extends MondrianOlap4jCellSet
394        {
395            public MondrianOlap4jCellSetJdbc4(
396                MondrianOlap4jStatement olap4jStatement,
397                Query query)
398            {
399                super(olap4jStatement, query);
400            }
401    
402            // implement java.sql.CellSet methods
403            // introduced in JDBC 4.0/JDK 1.6
404    
405            public RowId getRowId(int columnIndex) throws SQLException {
406                throw new UnsupportedOperationException();
407            }
408    
409            public RowId getRowId(String columnLabel) throws SQLException {
410                throw new UnsupportedOperationException();
411            }
412    
413            public void updateRowId(int columnIndex, RowId x) throws SQLException {
414                throw new UnsupportedOperationException();
415            }
416    
417            public void updateRowId(String columnLabel, RowId x) throws SQLException {
418                throw new UnsupportedOperationException();
419            }
420    
421            public int getHoldability() throws SQLException {
422                throw new UnsupportedOperationException();
423            }
424    
425            public boolean isClosed() throws SQLException {
426                return closed;
427            }
428    
429            public void updateNString(
430                int columnIndex, String nString) throws SQLException {
431                throw new UnsupportedOperationException();
432            }
433    
434            public void updateNString(
435                String columnLabel, String nString) throws SQLException {
436                throw new UnsupportedOperationException();
437            }
438    
439            public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
440                throw new UnsupportedOperationException();
441            }
442    
443            public void updateNClob(
444                String columnLabel, NClob nClob) throws SQLException {
445                throw new UnsupportedOperationException();
446            }
447    
448            public NClob getNClob(int columnIndex) throws SQLException {
449                throw new UnsupportedOperationException();
450            }
451    
452            public NClob getNClob(String columnLabel) throws SQLException {
453                throw new UnsupportedOperationException();
454            }
455    
456            public SQLXML getSQLXML(int columnIndex) throws SQLException {
457                throw new UnsupportedOperationException();
458            }
459    
460            public SQLXML getSQLXML(String columnLabel) throws SQLException {
461                throw new UnsupportedOperationException();
462            }
463    
464            public void updateSQLXML(
465                int columnIndex, SQLXML xmlObject) throws SQLException {
466                throw new UnsupportedOperationException();
467            }
468    
469            public void updateSQLXML(
470                String columnLabel, SQLXML xmlObject) throws SQLException {
471                throw new UnsupportedOperationException();
472            }
473    
474            public String getNString(int columnIndex) throws SQLException {
475                throw new UnsupportedOperationException();
476            }
477    
478            public String getNString(String columnLabel) throws SQLException {
479                throw new UnsupportedOperationException();
480            }
481    
482            public Reader getNCharacterStream(int columnIndex) throws SQLException {
483                throw new UnsupportedOperationException();
484            }
485    
486            public Reader getNCharacterStream(String columnLabel) throws SQLException {
487                throw new UnsupportedOperationException();
488            }
489    
490            public void updateNCharacterStream(
491                int columnIndex, Reader x, long length) throws SQLException {
492                throw new UnsupportedOperationException();
493            }
494    
495            public void updateNCharacterStream(
496                String columnLabel, Reader reader, long length) throws SQLException {
497                throw new UnsupportedOperationException();
498            }
499    
500            public void updateAsciiStream(
501                int columnIndex, InputStream x, long length) throws SQLException {
502                throw new UnsupportedOperationException();
503            }
504    
505            public void updateBinaryStream(
506                int columnIndex, InputStream x, long length) throws SQLException {
507                throw new UnsupportedOperationException();
508            }
509    
510            public void updateCharacterStream(
511                int columnIndex, Reader x, long length) throws SQLException {
512                throw new UnsupportedOperationException();
513            }
514    
515            public void updateAsciiStream(
516                String columnLabel, InputStream x, long length) throws SQLException {
517                throw new UnsupportedOperationException();
518            }
519    
520            public void updateBinaryStream(
521                String columnLabel, InputStream x, long length) throws SQLException {
522                throw new UnsupportedOperationException();
523            }
524    
525            public void updateCharacterStream(
526                String columnLabel, Reader reader, long length) throws SQLException {
527                throw new UnsupportedOperationException();
528            }
529    
530            public void updateBlob(
531                int columnIndex,
532                InputStream inputStream,
533                long length) throws SQLException {
534                throw new UnsupportedOperationException();
535            }
536    
537            public void updateBlob(
538                String columnLabel,
539                InputStream inputStream,
540                long length) throws SQLException {
541                throw new UnsupportedOperationException();
542            }
543    
544            public void updateClob(
545                int columnIndex, Reader reader, long length) throws SQLException {
546                throw new UnsupportedOperationException();
547            }
548    
549            public void updateClob(
550                String columnLabel, Reader reader, long length) throws SQLException {
551                throw new UnsupportedOperationException();
552            }
553    
554            public void updateNClob(
555                int columnIndex, Reader reader, long length) throws SQLException {
556                throw new UnsupportedOperationException();
557            }
558    
559            public void updateNClob(
560                String columnLabel, Reader reader, long length) throws SQLException {
561                throw new UnsupportedOperationException();
562            }
563    
564            public void updateNCharacterStream(
565                int columnIndex, Reader x) throws SQLException {
566                throw new UnsupportedOperationException();
567            }
568    
569            public void updateNCharacterStream(
570                String columnLabel, Reader reader) throws SQLException {
571                throw new UnsupportedOperationException();
572            }
573    
574            public void updateAsciiStream(
575                int columnIndex, InputStream x) throws SQLException {
576                throw new UnsupportedOperationException();
577            }
578    
579            public void updateBinaryStream(
580                int columnIndex, InputStream x) throws SQLException {
581                throw new UnsupportedOperationException();
582            }
583    
584            public void updateCharacterStream(
585                int columnIndex, Reader x) throws SQLException {
586                throw new UnsupportedOperationException();
587            }
588    
589            public void updateAsciiStream(
590                String columnLabel, InputStream x) throws SQLException {
591                throw new UnsupportedOperationException();
592            }
593    
594            public void updateBinaryStream(
595                String columnLabel, InputStream x) throws SQLException {
596                throw new UnsupportedOperationException();
597            }
598    
599            public void updateCharacterStream(
600                String columnLabel, Reader reader) throws SQLException {
601                throw new UnsupportedOperationException();
602            }
603    
604            public void updateBlob(
605                int columnIndex, InputStream inputStream) throws SQLException {
606                throw new UnsupportedOperationException();
607            }
608    
609            public void updateBlob(
610                String columnLabel, InputStream inputStream) throws SQLException {
611                throw new UnsupportedOperationException();
612            }
613    
614            public void updateClob(int columnIndex, Reader reader) throws SQLException {
615                throw new UnsupportedOperationException();
616            }
617    
618            public void updateClob(
619                String columnLabel, Reader reader) throws SQLException {
620                throw new UnsupportedOperationException();
621            }
622    
623            public void updateNClob(
624                int columnIndex, Reader reader) throws SQLException {
625                throw new UnsupportedOperationException();
626            }
627    
628            public void updateNClob(
629                String columnLabel, Reader reader) throws SQLException {
630                throw new UnsupportedOperationException();
631            }
632        }
633    
634        private static class MondrianOlap4jPreparedStatementJdbc4
635            extends MondrianOlap4jPreparedStatement
636        {
637            public MondrianOlap4jPreparedStatementJdbc4(
638                MondrianOlap4jConnection olap4jConnection,
639                String mdx)
640            {
641                super(olap4jConnection, mdx);
642            }
643    
644            public CellSetMetaData getMetaData() {
645                return super.getMetaData();
646            }
647    
648            // implement java.sql.PreparedStatement methods
649            // introduced in JDBC 4.0/JDK 1.6
650    
651            public void setRowId(int parameterIndex, RowId x) throws SQLException {
652                throw new UnsupportedOperationException();
653            }
654    
655            public void setNString(
656                int parameterIndex, String value) throws SQLException {
657                throw new UnsupportedOperationException();
658            }
659    
660            public void setNCharacterStream(
661                int parameterIndex, Reader value, long length) throws SQLException {
662                throw new UnsupportedOperationException();
663            }
664    
665            public void setNClob(int parameterIndex, NClob value) throws SQLException {
666                throw new UnsupportedOperationException();
667            }
668    
669            public void setClob(
670                int parameterIndex, Reader reader, long length) throws SQLException {
671                throw new UnsupportedOperationException();
672            }
673    
674            public void setBlob(
675                int parameterIndex,
676                InputStream inputStream,
677                long length) throws SQLException {
678                throw new UnsupportedOperationException();
679            }
680    
681            public void setNClob(
682                int parameterIndex, Reader reader, long length) throws SQLException {
683                throw new UnsupportedOperationException();
684            }
685    
686            public void setSQLXML(
687                int parameterIndex, SQLXML xmlObject) throws SQLException {
688                throw new UnsupportedOperationException();
689            }
690    
691            public void setAsciiStream(
692                int parameterIndex, InputStream x, long length) throws SQLException {
693                throw new UnsupportedOperationException();
694            }
695    
696            public void setBinaryStream(
697                int parameterIndex, InputStream x, long length) throws SQLException {
698                throw new UnsupportedOperationException();
699            }
700    
701            public void setCharacterStream(
702                int parameterIndex, Reader reader, long length) throws SQLException {
703                throw new UnsupportedOperationException();
704            }
705    
706            public void setAsciiStream(
707                int parameterIndex, InputStream x) throws SQLException {
708                throw new UnsupportedOperationException();
709            }
710    
711            public void setBinaryStream(
712                int parameterIndex, InputStream x) throws SQLException {
713                throw new UnsupportedOperationException();
714            }
715    
716            public void setCharacterStream(
717                int parameterIndex, Reader reader) throws SQLException {
718                throw new UnsupportedOperationException();
719            }
720    
721            public void setNCharacterStream(
722                int parameterIndex, Reader value) throws SQLException {
723                throw new UnsupportedOperationException();
724            }
725    
726            public void setClob(int parameterIndex, Reader reader) throws SQLException {
727                throw new UnsupportedOperationException();
728            }
729    
730            public void setBlob(
731                int parameterIndex, InputStream inputStream) throws SQLException {
732                throw new UnsupportedOperationException();
733            }
734    
735            public void setNClob(
736                int parameterIndex, Reader reader) throws SQLException {
737                throw new UnsupportedOperationException();
738            }
739        }
740    
741        private static class MondrianOlap4jDatabaseMetaDataJdbc4
742            extends MondrianOlap4jDatabaseMetaData
743        {
744            public MondrianOlap4jDatabaseMetaDataJdbc4(
745                MondrianOlap4jConnection olap4jConnection)
746            {
747                super(olap4jConnection);
748            }
749    
750            public OlapConnection getConnection() {
751                return super.getConnection();
752            }
753    
754            // implement java.sql.DatabaseMetaData methods
755            // introduced in JDBC 4.0/JDK 1.6
756    
757            public RowIdLifetime getRowIdLifetime() throws SQLException {
758                throw new UnsupportedOperationException();
759            }
760    
761            public ResultSet getSchemas(
762                String catalog, String schemaPattern) throws SQLException {
763                throw new UnsupportedOperationException();
764            }
765    
766            public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
767                throw new UnsupportedOperationException();
768            }
769    
770            public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
771                throw new UnsupportedOperationException();
772            }
773    
774            public ResultSet getClientInfoProperties() throws SQLException {
775                throw new UnsupportedOperationException();
776            }
777    
778            public ResultSet getFunctions(
779                String catalog,
780                String schemaPattern,
781                String functionNamePattern) throws SQLException
782            {
783                throw new UnsupportedOperationException();
784            }
785    
786            public ResultSet getFunctionColumns(
787                String catalog,
788                String schemaPattern,
789                String functionNamePattern,
790                String columnNamePattern) throws SQLException
791            {
792                throw new UnsupportedOperationException();
793            }
794        }
795    }
796    
797    // End FactoryJdbc4Impl.java