KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > client > net > NetDatabaseMetaData40


1 /*
2  
3    Derby - Class org.apache.derby.client.net.NetDatabaseMetaData40
4  
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to You under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11  
12       http://www.apache.org/licenses/LICENSE-2.0
13  
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19  
20  */

21
22 package org.apache.derby.client.net;
23
24 import java.sql.ResultSet JavaDoc;
25 import java.sql.RowIdLifetime JavaDoc;
26 import java.sql.SQLException JavaDoc;
27 import org.apache.derby.client.am.ClientMessageId;
28 import org.apache.derby.client.am.SqlException;
29 import org.apache.derby.client.am.SQLExceptionFactory;
30 import org.apache.derby.shared.common.reference.SQLState;
31
32 public class NetDatabaseMetaData40 extends org.apache.derby.client.net.NetDatabaseMetaData {
33     
34     
35     public NetDatabaseMetaData40(NetAgent netAgent, NetConnection netConnection) {
36         super(netAgent,netConnection);
37     }
38
39     /**
40      * Retrieves the major JDBC version number for this driver.
41      * @return JDBC version major number
42      * @exception SQLException if the connection is closed
43      */

44     public int getJDBCMajorVersion() throws SQLException JavaDoc {
45         checkForClosedConnection();
46         return 4;
47     }
48
49     /**
50      * Retrieves the minor JDBC version number for this driver.
51      * @return JDBC version minor number
52      * @exception SQLException if the connection is closed
53      */

54     public int getJDBCMinorVersion() throws SQLException JavaDoc {
55         checkForClosedConnection();
56         return 0;
57     }
58
59     /**
60      * Indicates whether or not this data source supports the SQL
61      * <code>ROWID</code> type. Since Derby does not support the
62      * <code>ROWID</code> type, return <code>ROWID_UNSUPPORTED</code>.
63      *
64      * @return <code>ROWID_UNSUPPORTED</code>
65      * @exception SQLException if a database access error occurs
66      */

67     public RowIdLifetime JavaDoc getRowIdLifetime() throws SQLException JavaDoc {
68         checkForClosedConnection();
69         return RowIdLifetime.ROWID_UNSUPPORTED;
70     }
71     
72     /**
73      * Returns false unless <code>interfaces</code> is implemented
74      *
75      * @param interfaces a Class defining an interface.
76      * @return true if this implements the interface or
77      * directly or indirectly wraps an object
78      * that does.
79      * @throws java.sql.SQLException if an error occurs while determining
80      * whether this is a wrapper for an object
81      * with the given interface.
82      */

83     public boolean isWrapperFor(Class JavaDoc<?> interfaces) throws SQLException JavaDoc {
84         return interfaces.isInstance(this);
85     }
86     
87     /**
88      * Returns <code>this</code> if this class implements the interface
89      *
90      * @param interfaces a Class defining an interface
91      * @return an object that implements the interface
92      * @throws java.sql.SQLExption if no object if found that implements the
93      * interface
94      */

95     public <T> T unwrap(java.lang.Class JavaDoc<T> interfaces)
96                                    throws SQLException JavaDoc {
97         try {
98             return interfaces.cast(this);
99         } catch (ClassCastException JavaDoc cce) {
100             throw new SqlException(null,
101                 new ClientMessageId(SQLState.UNABLE_TO_UNWRAP),
102                 interfaces).getSQLException();
103         }
104     }
105 }
106
Popular Tags