KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > jdbc > EmbedDatabaseMetaData40


1 /*
2
3    Derby - Class org.apache.derby.impl.jdbc.EmbedDatabaseMetaData40
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.impl.jdbc;
23
24 import java.sql.ResultSet JavaDoc;
25 import java.sql.RowIdLifetime JavaDoc;
26 import java.sql.DatabaseMetaData JavaDoc;
27 import java.sql.SQLException JavaDoc;
28 import java.sql.PreparedStatement JavaDoc;
29 import org.apache.derby.impl.jdbc.Util;
30 import org.apache.derby.iapi.reference.SQLState;
31
32
33 public class EmbedDatabaseMetaData40 extends EmbedDatabaseMetaData {
34     
35     private final String JavaDoc url;
36     
37     public EmbedDatabaseMetaData40(EmbedConnection connection, String JavaDoc url) throws SQLException JavaDoc {
38         super(connection,url);
39         this.url = url;
40     }
41
42     /**
43      * Retrieves the major JDBC version number for this driver.
44      *
45      * @return JDBC version major number
46      */

47     public int getJDBCMajorVersion() {
48         return 4;
49     }
50
51     /**
52      * Retrieves the minor JDBC version number for this driver.
53      *
54      * @return JDBC version minor number
55      */

56     public int getJDBCMinorVersion() {
57         return 0;
58     }
59
60     public RowIdLifetime JavaDoc getRowIdLifetime() throws SQLException JavaDoc {
61         return RowIdLifetime.ROWID_UNSUPPORTED;
62     }
63
64     public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException JavaDoc {
65         return true;
66     }
67      
68     public boolean autoCommitFailureClosesAllResultSets() throws SQLException JavaDoc {
69         // TODO - find out what this really should be
70
return false;
71     }
72    
73     public boolean providesQueryObjectGenerator() throws SQLException JavaDoc {
74         return false;
75     }
76
77     
78     /**
79      * Returns false unless <code>interfaces</code> is implemented
80      *
81      * @param interfaces a Class defining an interface.
82      * @return true if this implements the interface or
83      * directly or indirectly wraps an object
84      * that does.
85      * @throws java.sql.SQLException if an error occurs while determining
86      * whether this is a wrapper for an object
87      * with the given interface.
88      */

89     public boolean isWrapperFor(Class JavaDoc<?> interfaces) throws SQLException JavaDoc {
90         return interfaces.isInstance(this);
91     }
92     
93     /**
94      * Returns <code>this</code> if this class implements the interface
95      *
96      * @param interfaces a Class defining an interface
97      * @return an object that implements the interface
98      * @throws java.sql.SQLExption if no object if found that implements the
99      * interface
100      */

101     public <T> T unwrap(java.lang.Class JavaDoc<T> interfaces)
102                             throws SQLException JavaDoc{
103         //Derby does not implement non-standard methods on
104
//JDBC objects
105
//hence return this if this class implements the interface
106
//or throw an SQLException
107
try {
108             return interfaces.cast(this);
109         } catch (ClassCastException JavaDoc cce) {
110             throw newSQLException(SQLState.UNABLE_TO_UNWRAP,interfaces);
111         }
112     }
113
114 }
115
Popular Tags