From a411fbc2d1b39071a94827f3632ced701b9907fd Mon Sep 17 00:00:00 2001 From: Julian Hyde Date: Mon, 7 Nov 2011 17:48:00 +0000 Subject: [PATCH] Enable build on JDK 1.7 (JDBC 4.1). git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@479 c6a108a4-781c-0410-a6c6-c2d559e19af0 --- build.xml | 67 +- buildJdk16.sh | 10 - buildJdk16.bat => buildOnJdk.bat | 2 +- buildOnJdk.sh | 27 + src/org/olap4j/driver/xmla/Factory.java | 10 + .../olap4j/driver/xmla/FactoryJdbc4Impl.java | 822 +----------------- .../driver/xmla/XmlaOlap4jConnection.java | 2 +- .../olap4j/driver/xmla/XmlaOlap4jDriver.java | 46 + .../driver/xmla/XmlaOlap4jStatement.java | 2 +- 9 files changed, 168 insertions(+), 820 deletions(-) delete mode 100755 buildJdk16.sh rename buildJdk16.bat => buildOnJdk.bat (87%) create mode 100755 buildOnJdk.sh diff --git a/build.xml b/build.xml index e6b9ace..9e5d229 100644 --- a/build.xml +++ b/build.xml @@ -3,7 +3,7 @@ == This software is subject to the terms of the Eclipse Public License v1.0 == Agreement, available at the following URL: == http://www.eclipse.org/legal/epl-v10.html. - == Copyright (C) 2006-2010 Julian Hyde and others. + == Copyright (C) 2006-2011 Julian Hyde and others. == All Rights Reserved. == You must accept the terms of that agreement to use this software. --> @@ -24,10 +24,19 @@ ${src.dir}/org/olap4j/mdx/parser/impl/DefaultMdxParser.java, ${src.dir}/org/olap4j/mdx/parser/impl/DefaultMdxParserSym.java" /> - + + + + + + + + + + @@ -39,6 +48,16 @@ ${src.dir}/org/olap4j/mdx/parser/impl/DefaultMdxParserSym.java" /> + + + + + + + + + + @@ -89,7 +108,7 @@ olap4j_api.pdf" - + + + + + + + + + - - + + - - + + + + + + + + + + + @@ -157,8 +194,8 @@ xmla-cache/**, .project, build.properties, build.xml, -buildJdk16.bat, -buildJdk16.sh, +buildOnJdk16.bat, +buildOnJdk16.sh, CHANGES.txt, checkFile.sh, checkFile.awk, @@ -290,9 +327,13 @@ class XmlaOlap4jDriverVersion { + if="jdk15.not.present" /> + + @@ -407,7 +448,7 @@ class XmlaOlap4jDriverVersion { - + @@ -426,7 +467,7 @@ class XmlaOlap4jDriverVersion { - + @@ -450,7 +491,7 @@ class XmlaOlap4jDriverVersion { - + diff --git a/buildJdk16.sh b/buildJdk16.sh deleted file mode 100755 index 2994f02..0000000 --- a/buildJdk16.sh +++ /dev/null @@ -1,10 +0,0 @@ -# $Id$ -# Called recursively from 'ant release' to build the files which can only be -# built under JDK 1.6. - -# Change the following line to point to your JDK 1.6 home. -export JAVA_HOME=/usr/local/jdk1.6 -export PATH=$JAVA_HOME/bin:$PATH -ant compile.compile - -# End buildJdk16.sh diff --git a/buildJdk16.bat b/buildOnJdk.bat similarity index 87% rename from buildJdk16.bat rename to buildOnJdk.bat index 5ab8df8..b65ee15 100755 --- a/buildJdk16.bat +++ b/buildOnJdk.bat @@ -1,5 +1,5 @@ @echo off -rem $Id$ +rem $Id: buildJdk16.bat 207 2009-05-05 14:58:00Z lucboudreau $ rem Called recursively from 'ant release' to build the files which can only be rem built under JDK 1.6. diff --git a/buildOnJdk.sh b/buildOnJdk.sh new file mode 100755 index 0000000..666fab8 --- /dev/null +++ b/buildOnJdk.sh @@ -0,0 +1,27 @@ +# $Id: //open/mondrian/buildJdk16.sh#3 $ +# Called recursively from 'ant release' to build the files which can only be +# built under a particular JDK version. +# +# Usage: +# buildOnJdk.sh +# +# For example: +# buildOnJdk.sh jdk1.6 compile.java + +jdkVersion=$1 +shift + +# Change the following line to point each JDK's home. +case "$jdkVersion" in +(*) export JAVA_HOME=/usr/lib/jvm/${jdkVersion};; +esac + +if [ ! -d "$JAVA_HOME" ]; then + echo "$0: Invalid JAVA_HOME $JAVA_HOME; skipping compile." + exit 1 +fi + +export PATH=$JAVA_HOME/bin:$PATH +ant -Dskip.download=true "$@" + +# End buildOnJdk.sh diff --git a/src/org/olap4j/driver/xmla/Factory.java b/src/org/olap4j/driver/xmla/Factory.java index afe7016..44bd7b4 100644 --- a/src/org/olap4j/driver/xmla/Factory.java +++ b/src/org/olap4j/driver/xmla/Factory.java @@ -9,6 +9,7 @@ package org.olap4j.driver.xmla; import org.olap4j.OlapException; +import org.olap4j.OlapStatement; import org.olap4j.driver.xmla.proxy.XmlaOlap4jProxy; import java.sql.*; @@ -75,6 +76,15 @@ ResultSet newFixedResultSet( XmlaOlap4jCellSet newCellSet( XmlaOlap4jStatement olap4jStatement) throws OlapException; + /** + * Creates a statement. + * + * @param olap4jConnection Connection + * @return Statement + */ + XmlaOlap4jStatement newStatement( + XmlaOlap4jConnection olap4jConnection); + /** * Creates a prepared statement. * diff --git a/src/org/olap4j/driver/xmla/FactoryJdbc4Impl.java b/src/org/olap4j/driver/xmla/FactoryJdbc4Impl.java index 742a1b8..4f3ed72 100644 --- a/src/org/olap4j/driver/xmla/FactoryJdbc4Impl.java +++ b/src/org/olap4j/driver/xmla/FactoryJdbc4Impl.java @@ -8,11 +8,9 @@ */ package org.olap4j.driver.xmla; -import org.olap4j.*; +import org.olap4j.OlapException; import org.olap4j.driver.xmla.proxy.XmlaOlap4jProxy; -import java.io.InputStream; -import java.io.Reader; import java.sql.*; import java.util.*; @@ -64,6 +62,12 @@ public XmlaOlap4jCellSet newCellSet( return new XmlaOlap4jCellSetJdbc4(olap4jStatement); } + public XmlaOlap4jStatement newStatement( + XmlaOlap4jConnection olap4jConnection) + { + return new XmlaOlap4jStatementJdbc4(olap4jConnection); + } + public XmlaOlap4jPreparedStatement newPreparedStatement( String mdx, XmlaOlap4jConnection olap4jConnection) throws OlapException @@ -79,7 +83,9 @@ public XmlaOlap4jDatabaseMetaData newDatabaseMetaData( // Inner classes - private static class EmptyResultSetJdbc4 extends EmptyResultSet { + private static class EmptyResultSetJdbc4 + extends FactoryJdbc4Plus.AbstractEmptyResultSet + { /** * Creates a EmptyResultSetJdbc4. * @@ -94,285 +100,10 @@ private static class EmptyResultSetJdbc4 extends EmptyResultSet { { super(olap4jConnection, headerList, rowList); } - - // implement java.sql.ResultSet methods - // introduced in JDBC 4.0/JDK 1.6 - - public RowId getRowId(int columnIndex) throws SQLException { - throw new UnsupportedOperationException(); - } - - public RowId getRowId(String columnLabel) throws SQLException { - throw new UnsupportedOperationException(); - } - - public void updateRowId(int columnIndex, RowId x) throws SQLException { - throw new UnsupportedOperationException(); - } - - public void updateRowId(String columnLabel, RowId x) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public int getHoldability() throws SQLException { - throw new UnsupportedOperationException(); - } - - public boolean isClosed() throws SQLException { - throw new UnsupportedOperationException(); - } - - public void updateNString( - int columnIndex, String nString) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNString( - String columnLabel, String nString) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNClob(int columnIndex, NClob nClob) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNClob( - String columnLabel, NClob nClob) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public NClob getNClob(int columnIndex) throws SQLException { - throw new UnsupportedOperationException(); - } - - public NClob getNClob(String columnLabel) throws SQLException { - throw new UnsupportedOperationException(); - } - - public SQLXML getSQLXML(int columnIndex) throws SQLException { - throw new UnsupportedOperationException(); - } - - public SQLXML getSQLXML(String columnLabel) throws SQLException { - throw new UnsupportedOperationException(); - } - - public void updateSQLXML( - int columnIndex, SQLXML xmlObject) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateSQLXML( - String columnLabel, SQLXML xmlObject) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public String getNString(int columnIndex) throws SQLException { - throw new UnsupportedOperationException(); - } - - public String getNString(String columnLabel) throws SQLException { - throw new UnsupportedOperationException(); - } - - public Reader getNCharacterStream(int columnIndex) throws SQLException { - throw new UnsupportedOperationException(); - } - - public Reader getNCharacterStream(String columnLabel) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNCharacterStream( - int columnIndex, Reader x, long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNCharacterStream( - String columnLabel, Reader reader, long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateAsciiStream( - int columnIndex, InputStream x, long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateBinaryStream( - int columnIndex, InputStream x, long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateCharacterStream( - int columnIndex, Reader x, long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateAsciiStream( - String columnLabel, InputStream x, long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateBinaryStream( - String columnLabel, InputStream x, long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateCharacterStream( - String columnLabel, Reader reader, long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateBlob( - int columnIndex, - InputStream inputStream, - long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateBlob( - String columnLabel, - InputStream inputStream, - long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateClob( - int columnIndex, Reader reader, long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateClob( - String columnLabel, Reader reader, long length) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNClob( - int columnIndex, Reader reader, long length) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNClob( - String columnLabel, Reader reader, long length) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNCharacterStream( - int columnIndex, Reader x) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNCharacterStream( - String columnLabel, Reader reader) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateAsciiStream( - int columnIndex, InputStream x) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateBinaryStream( - int columnIndex, InputStream x) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateCharacterStream( - int columnIndex, Reader x) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateAsciiStream( - String columnLabel, InputStream x) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateBinaryStream( - String columnLabel, InputStream x) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateCharacterStream( - String columnLabel, Reader reader) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateBlob( - int columnIndex, InputStream inputStream) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateBlob( - String columnLabel, InputStream inputStream) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateClob( - int columnIndex, Reader reader) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateClob( - String columnLabel, Reader reader) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNClob( - int columnIndex, Reader reader) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNClob( - String columnLabel, Reader reader) throws SQLException - { - throw new UnsupportedOperationException(); - } } private static class XmlaOlap4jConnectionJdbc4 - extends XmlaOlap4jConnection - implements OlapConnection + extends FactoryJdbc4Plus.AbstractConnection { /** * Creates a XmlaOlap4jConnectionJdbc4. @@ -393,72 +124,11 @@ public XmlaOlap4jConnectionJdbc4( { super(factory, driver, proxy, url, info); } - - public OlapStatement createStatement() { - return super.createStatement(); - } - - public OlapDatabaseMetaData getMetaData() { - return super.getMetaData(); - } - - // implement java.sql.Connection methods - // introduced in JDBC 4.0/JDK 1.6 - - public Clob createClob() throws SQLException { - throw new UnsupportedOperationException(); - } - - public Blob createBlob() throws SQLException { - throw new UnsupportedOperationException(); - } - - public NClob createNClob() throws SQLException { - throw new UnsupportedOperationException(); - } - - public SQLXML createSQLXML() throws SQLException { - throw new UnsupportedOperationException(); - } - - public boolean isValid(int timeout) throws SQLException { - return !isClosed(); - } - - public void setClientInfo( - String name, String value) throws SQLClientInfoException - { - throw new UnsupportedOperationException(); - } - - public void setClientInfo(Properties properties) - throws SQLClientInfoException - { - throw new UnsupportedOperationException(); - } - - public String getClientInfo(String name) throws SQLException { - throw new UnsupportedOperationException(); - } - - public Properties getClientInfo() throws SQLException { - throw new UnsupportedOperationException(); - } - - public Array createArrayOf( - String typeName, Object[] elements) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public Struct createStruct( - String typeName, Object[] attributes) throws SQLException - { - throw new UnsupportedOperationException(); - } } - private static class XmlaOlap4jCellSetJdbc4 extends XmlaOlap4jCellSet { + private static class XmlaOlap4jCellSetJdbc4 + extends FactoryJdbc4Plus.AbstractCellSet + { /** * Creates an XmlaOlap4jCellSetJdbc4. * @@ -471,291 +141,25 @@ private static class XmlaOlap4jCellSetJdbc4 extends XmlaOlap4jCellSet { { super(olap4jStatement); } + } - public CellSetMetaData getMetaData() { - return super.getMetaData(); - } - - // implement java.sql.CellSet methods - // introduced in JDBC 4.0/JDK 1.6 - - public RowId getRowId(int columnIndex) throws SQLException { - throw new UnsupportedOperationException(); - } - - public RowId getRowId(String columnLabel) throws SQLException { - throw new UnsupportedOperationException(); - } - - public void updateRowId(int columnIndex, RowId x) throws SQLException { - throw new UnsupportedOperationException(); - } - - public void updateRowId(String columnLabel, RowId x) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public int getHoldability() throws SQLException { - throw new UnsupportedOperationException(); - } - - public boolean isClosed() throws SQLException { - return closed; - } - - public void updateNString( - int columnIndex, String nString) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNString( - String columnLabel, String nString) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNClob(int columnIndex, NClob nClob) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNClob( - String columnLabel, NClob nClob) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public NClob getNClob(int columnIndex) throws SQLException { - throw new UnsupportedOperationException(); - } - - public NClob getNClob(String columnLabel) throws SQLException { - throw new UnsupportedOperationException(); - } - - public SQLXML getSQLXML(int columnIndex) throws SQLException { - throw new UnsupportedOperationException(); - } - - public SQLXML getSQLXML(String columnLabel) throws SQLException { - throw new UnsupportedOperationException(); - } - - public void updateSQLXML( - int columnIndex, SQLXML xmlObject) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateSQLXML( - String columnLabel, SQLXML xmlObject) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public String getNString(int columnIndex) throws SQLException { - throw new UnsupportedOperationException(); - } - - public String getNString(String columnLabel) throws SQLException { - throw new UnsupportedOperationException(); - } - - public Reader getNCharacterStream(int columnIndex) throws SQLException { - throw new UnsupportedOperationException(); - } - - public Reader getNCharacterStream(String columnLabel) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNCharacterStream( - int columnIndex, Reader x, long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNCharacterStream( - String columnLabel, Reader reader, long length) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateAsciiStream( - int columnIndex, InputStream x, long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateBinaryStream( - int columnIndex, InputStream x, long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateCharacterStream( - int columnIndex, Reader x, long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateAsciiStream( - String columnLabel, InputStream x, long length) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateBinaryStream( - String columnLabel, InputStream x, long length) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateCharacterStream( - String columnLabel, Reader reader, long length) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateBlob( - int columnIndex, - InputStream inputStream, - long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateBlob( - String columnLabel, - InputStream inputStream, - long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateClob( - int columnIndex, Reader reader, long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateClob( - String columnLabel, Reader reader, long length) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNClob( - int columnIndex, Reader reader, long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNClob( - String columnLabel, Reader reader, long length) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNCharacterStream( - int columnIndex, Reader x) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNCharacterStream( - String columnLabel, Reader reader) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateAsciiStream( - int columnIndex, InputStream x) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateBinaryStream( - int columnIndex, InputStream x) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateCharacterStream( - int columnIndex, Reader x) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateAsciiStream( - String columnLabel, InputStream x) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateBinaryStream( - String columnLabel, InputStream x) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateCharacterStream( - String columnLabel, Reader reader) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateBlob( - int columnIndex, InputStream inputStream) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateBlob( - String columnLabel, InputStream inputStream) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateClob(int columnIndex, Reader reader) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateClob( - String columnLabel, Reader reader) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNClob( - int columnIndex, Reader reader) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void updateNClob( - String columnLabel, Reader reader) throws SQLException + private static class XmlaOlap4jStatementJdbc4 + extends XmlaOlap4jStatement + { + /** + * Creates a XmlaOlap4jStatementJdbc4. + * + * @param olap4jConnection Connection + */ + XmlaOlap4jStatementJdbc4( + XmlaOlap4jConnection olap4jConnection) { - throw new UnsupportedOperationException(); + super(olap4jConnection); } } private static class XmlaOlap4jPreparedStatementJdbc4 - extends XmlaOlap4jPreparedStatement + extends FactoryJdbc4Plus.AbstractPreparedStatement { /** * Creates a XmlaOlap4jPreparedStatementJdbc4. @@ -770,130 +174,10 @@ private static class XmlaOlap4jPreparedStatementJdbc4 { super(olap4jConnection, mdx); } - - public CellSetMetaData getMetaData() { - return super.getMetaData(); - } - - // implement java.sql.PreparedStatement methods - // introduced in JDBC 4.0/JDK 1.6 - - public void setRowId(int parameterIndex, RowId x) throws SQLException { - throw new UnsupportedOperationException(); - } - - public void setNString( - int parameterIndex, String value) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void setNCharacterStream( - int parameterIndex, Reader value, long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void setNClob(int parameterIndex, NClob value) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void setClob( - int parameterIndex, Reader reader, long length) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void setBlob( - int parameterIndex, - InputStream inputStream, - long length) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void setNClob( - int parameterIndex, Reader reader, long length) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void setSQLXML( - int parameterIndex, SQLXML xmlObject) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void setAsciiStream( - int parameterIndex, InputStream x, long length) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void setBinaryStream( - int parameterIndex, InputStream x, long length) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void setCharacterStream( - int parameterIndex, Reader reader, long length) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void setAsciiStream( - int parameterIndex, InputStream x) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void setBinaryStream( - int parameterIndex, InputStream x) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void setCharacterStream( - int parameterIndex, Reader reader) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void setNCharacterStream( - int parameterIndex, Reader value) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void setClob(int parameterIndex, Reader reader) - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void setBlob( - int parameterIndex, InputStream inputStream) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public void setNClob( - int parameterIndex, Reader reader) throws SQLException - { - throw new UnsupportedOperationException(); - } } private static class XmlaOlap4jDatabaseMetaDataJdbc4 - extends XmlaOlap4jDatabaseMetaData + extends FactoryJdbc4Plus.AbstractDatabaseMetaData { /** * Creates an XmlaOlap4jDatabaseMetaDataJdbc4. @@ -905,56 +189,6 @@ private static class XmlaOlap4jDatabaseMetaDataJdbc4 { super(olap4jConnection); } - - public OlapConnection getConnection() { - return super.getConnection(); - } - - // implement java.sql.DatabaseMetaData methods - // introduced in JDBC 4.0/JDK 1.6 - - public RowIdLifetime getRowIdLifetime() throws SQLException { - throw new UnsupportedOperationException(); - } - - public ResultSet getSchemas( - String catalog, String schemaPattern) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public boolean supportsStoredFunctionsUsingCallSyntax() - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public boolean autoCommitFailureClosesAllResultSets() - throws SQLException - { - throw new UnsupportedOperationException(); - } - - public ResultSet getClientInfoProperties() throws SQLException { - throw new UnsupportedOperationException(); - } - - public ResultSet getFunctions( - String catalog, - String schemaPattern, - String functionNamePattern) throws SQLException - { - throw new UnsupportedOperationException(); - } - - public ResultSet getFunctionColumns( - String catalog, - String schemaPattern, - String functionNamePattern, - String columnNamePattern) throws SQLException - { - throw new UnsupportedOperationException(); - } } } diff --git a/src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java b/src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java index 994afd0..2f541d1 100644 --- a/src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java +++ b/src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java @@ -288,7 +288,7 @@ static boolean acceptsURL(String url) { } public OlapStatement createStatement() { - return new XmlaOlap4jStatement(this); + return factory.newStatement(this); } public PreparedStatement prepareStatement(String sql) throws SQLException { diff --git a/src/org/olap4j/driver/xmla/XmlaOlap4jDriver.java b/src/org/olap4j/driver/xmla/XmlaOlap4jDriver.java index e383cb7..f168cc5 100644 --- a/src/org/olap4j/driver/xmla/XmlaOlap4jDriver.java +++ b/src/org/olap4j/driver/xmla/XmlaOlap4jDriver.java @@ -16,6 +16,7 @@ import java.sql.*; import java.util.*; import java.util.concurrent.*; +import java.util.logging.Logger; /** * Olap4j driver for generic XML for Analysis (XMLA) providers. @@ -132,6 +133,25 @@ public Thread newThread(Runnable r) { * Creates an XmlaOlap4jDriver. */ public XmlaOlap4jDriver() { + factory = createFactory(); + } + + private static Factory createFactory() { + final String factoryClassName = getFactoryClassName(); + try { + final Class clazz = Class.forName(factoryClassName); + return (Factory) clazz.newInstance(); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (InstantiationException e) { + throw new RuntimeException(e); + } + } + + /* + String factoryClassName; try { Class.forName("java.sql.Wrapper"); @@ -151,6 +171,27 @@ public XmlaOlap4jDriver() { } catch (InstantiationException e) { throw new RuntimeException(e); } + */ + + private static String getFactoryClassName() { + try { + // If java.sql.PseudoColumnUsage is present, we are running JDBC 4.1 + // or later. + Class.forName("java.sql.PseudoColumnUsage"); + return "org.olap4j.driver.xmla.FactoryJdbc41Impl"; + } catch (ClassNotFoundException e) { + // java.sql.PseudoColumnUsage is not present. This means we are + // running JDBC 4.0 or earlier. + try { + Class.forName("java.sql.Wrapper"); + return "org.olap4j.driver.xmla.FactoryJdbc4Impl"; + } catch (ClassNotFoundException e2) { + // java.sql.Wrapper is not present. This means we are running + // JDBC 3.0 or earlier (probably JDK 1.5). Load the JDBC 3.0 + // factory. + return "org.olap4j.driver.xmla.FactoryJdbc3Impl"; + } + } } /** @@ -231,6 +272,11 @@ public boolean jdbcCompliant() { return false; } + // for JDBC 4.1 + public Logger getParentLogger() { + return Logger.getLogger(""); + } + /** * Creates a Proxy with which to talk to send XML web-service calls. * The usual implementation of Proxy uses HTTP; there is another diff --git a/src/org/olap4j/driver/xmla/XmlaOlap4jStatement.java b/src/org/olap4j/driver/xmla/XmlaOlap4jStatement.java index e8c236c..9fedb85 100644 --- a/src/org/olap4j/driver/xmla/XmlaOlap4jStatement.java +++ b/src/org/olap4j/driver/xmla/XmlaOlap4jStatement.java @@ -23,7 +23,7 @@ * @version $Id$ * @since May 24, 2007 */ -class XmlaOlap4jStatement implements OlapStatement { +abstract class XmlaOlap4jStatement implements OlapStatement { final XmlaOlap4jConnection olap4jConnection; private boolean closed;