1 | /* |
---|
2 | Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. |
---|
3 | |
---|
4 | |
---|
5 | The MySQL Connector/J is licensed under the terms of the GPLv2 |
---|
6 | <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors. |
---|
7 | There are special exceptions to the terms and conditions of the GPLv2 as it is applied to |
---|
8 | this software, see the FLOSS License Exception |
---|
9 | <http://www.mysql.com/about/legal/licensing/foss-exception.html>. |
---|
10 | |
---|
11 | This program is free software; you can redistribute it and/or modify it under the terms |
---|
12 | of the GNU General Public License as published by the Free Software Foundation; version 2 |
---|
13 | of the License. |
---|
14 | |
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
---|
16 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
---|
17 | See the GNU General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU General Public License along with this |
---|
20 | program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth |
---|
21 | Floor, Boston, MA 02110-1301 USA |
---|
22 | |
---|
23 | */ |
---|
24 | |
---|
25 | package com.mysql.jdbc; |
---|
26 | |
---|
27 | import java.sql.ResultSet; |
---|
28 | import java.sql.RowIdLifetime; |
---|
29 | import java.sql.SQLException; |
---|
30 | import java.sql.Types; |
---|
31 | import java.util.ArrayList; |
---|
32 | |
---|
33 | import java.util.List; |
---|
34 | |
---|
35 | public class JDBC4DatabaseMetaDataUsingInfoSchema extends DatabaseMetaDataUsingInfoSchema { |
---|
36 | public JDBC4DatabaseMetaDataUsingInfoSchema(MySQLConnection connToSet, String databaseToSet) throws SQLException { |
---|
37 | super(connToSet, databaseToSet); |
---|
38 | } |
---|
39 | |
---|
40 | public RowIdLifetime getRowIdLifetime() throws SQLException { |
---|
41 | return RowIdLifetime.ROWID_UNSUPPORTED; |
---|
42 | } |
---|
43 | |
---|
44 | /** |
---|
45 | * Returns true if this either implements the interface argument or is directly or indirectly a wrapper |
---|
46 | * for an object that does. Returns false otherwise. If this implements the interface then return true, |
---|
47 | * else if this is a wrapper then return the result of recursively calling <code>isWrapperFor</code> on the wrapped |
---|
48 | * object. If this does not implement the interface and is not a wrapper, return false. |
---|
49 | * This method should be implemented as a low-cost operation compared to <code>unwrap</code> so that |
---|
50 | * callers can use this method to avoid expensive <code>unwrap</code> calls that may fail. If this method |
---|
51 | * returns true then calling <code>unwrap</code> with the same argument should succeed. |
---|
52 | * |
---|
53 | * @param interfaces a Class defining an interface. |
---|
54 | * @return true if this implements the interface or directly or indirectly wraps an object that does. |
---|
55 | * @throws java.sql.SQLException if an error occurs while determining whether this is a wrapper |
---|
56 | * for an object with the given interface. |
---|
57 | * @since 1.6 |
---|
58 | */ |
---|
59 | public boolean isWrapperFor(Class<?> iface) throws SQLException { |
---|
60 | // This works for classes that aren't actually wrapping |
---|
61 | // anything |
---|
62 | return iface.isInstance(this); |
---|
63 | } |
---|
64 | |
---|
65 | /** |
---|
66 | * Returns an object that implements the given interface to allow access to non-standard methods, |
---|
67 | * or standard methods not exposed by the proxy. |
---|
68 | * The result may be either the object found to implement the interface or a proxy for that object. |
---|
69 | * If the receiver implements the interface then that is the object. If the receiver is a wrapper |
---|
70 | * and the wrapped object implements the interface then that is the object. Otherwise the object is |
---|
71 | * the result of calling <code>unwrap</code> recursively on the wrapped object. If the receiver is not a |
---|
72 | * wrapper and does not implement the interface, then an <code>SQLException</code> is thrown. |
---|
73 | * |
---|
74 | * @param iface A Class defining an interface that the result must implement. |
---|
75 | * @return an object that implements the interface. May be a proxy for the actual implementing object. |
---|
76 | * @throws java.sql.SQLException If no object found that implements the interface |
---|
77 | * @since 1.6 |
---|
78 | */ |
---|
79 | public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException { |
---|
80 | try { |
---|
81 | // This works for classes that aren't actually wrapping |
---|
82 | // anything |
---|
83 | return iface.cast(this); |
---|
84 | } catch (ClassCastException cce) { |
---|
85 | throw SQLError.createSQLException("Unable to unwrap to " + iface.toString(), |
---|
86 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.conn.getExceptionInterceptor()); |
---|
87 | } |
---|
88 | } |
---|
89 | |
---|
90 | protected int getJDBC4FunctionNoTableConstant() { |
---|
91 | return functionNoTable; |
---|
92 | } |
---|
93 | } |
---|