001: /*
002:
003: Derby - Class org.apache.derby.impl.jdbc.EmbedDatabaseMetaData40
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.impl.jdbc;
023:
024: import java.sql.ResultSet;
025: import java.sql.RowIdLifetime;
026: import java.sql.DatabaseMetaData;
027: import java.sql.SQLException;
028: import java.sql.PreparedStatement;
029: import org.apache.derby.impl.jdbc.Util;
030: import org.apache.derby.iapi.reference.SQLState;
031:
032: public class EmbedDatabaseMetaData40 extends EmbedDatabaseMetaData {
033:
034: private final String url;
035:
036: public EmbedDatabaseMetaData40(EmbedConnection connection,
037: String url) throws SQLException {
038: super (connection, url);
039: this .url = url;
040: }
041:
042: /**
043: * Retrieves the major JDBC version number for this driver.
044: *
045: * @return JDBC version major number
046: */
047: public int getJDBCMajorVersion() {
048: return 4;
049: }
050:
051: /**
052: * Retrieves the minor JDBC version number for this driver.
053: *
054: * @return JDBC version minor number
055: */
056: public int getJDBCMinorVersion() {
057: return 0;
058: }
059:
060: public RowIdLifetime getRowIdLifetime() throws SQLException {
061: return RowIdLifetime.ROWID_UNSUPPORTED;
062: }
063:
064: public boolean supportsStoredFunctionsUsingCallSyntax()
065: throws SQLException {
066: return true;
067: }
068:
069: public boolean autoCommitFailureClosesAllResultSets()
070: throws SQLException {
071: // TODO - find out what this really should be
072: return false;
073: }
074:
075: public boolean providesQueryObjectGenerator() throws SQLException {
076: return false;
077: }
078:
079: /**
080: * Returns false unless <code>interfaces</code> is implemented
081: *
082: * @param interfaces a Class defining an interface.
083: * @return true if this implements the interface or
084: * directly or indirectly wraps an object
085: * that does.
086: * @throws java.sql.SQLException if an error occurs while determining
087: * whether this is a wrapper for an object
088: * with the given interface.
089: */
090: public boolean isWrapperFor(Class<?> interfaces)
091: throws SQLException {
092: return interfaces.isInstance(this );
093: }
094:
095: /**
096: * Returns <code>this</code> if this class implements the interface
097: *
098: * @param interfaces a Class defining an interface
099: * @return an object that implements the interface
100: * @throws java.sql.SQLExption if no object if found that implements the
101: * interface
102: */
103: public <T> T unwrap(java.lang.Class<T> interfaces)
104: throws SQLException {
105: //Derby does not implement non-standard methods on
106: //JDBC objects
107: //hence return this if this class implements the interface
108: //or throw an SQLException
109: try {
110: return interfaces.cast(this );
111: } catch (ClassCastException cce) {
112: throw newSQLException(SQLState.UNABLE_TO_UNWRAP, interfaces);
113: }
114: }
115:
116: }
|