KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > jdbc > Driver40


1 /*
2  
3    Derby - Class org.apache.derby.jdbc.Driver40
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.jdbc;
23
24 import java.sql.DatabaseMetaData JavaDoc;
25 import org.apache.derby.iapi.jdbc.BrokeredConnection;
26 import org.apache.derby.iapi.jdbc.BrokeredConnectionControl;
27 import org.apache.derby.iapi.jdbc.BrokeredConnection40;
28 import org.apache.derby.iapi.sql.ResultSet;
29 import org.apache.derby.iapi.services.sanity.SanityManager;
30 import org.apache.derby.iapi.error.StandardException;
31 import org.apache.derby.impl.jdbc.EmbedConnection;
32 import org.apache.derby.impl.jdbc.EmbedConnection30;
33 import org.apache.derby.impl.jdbc.EmbedPreparedStatement40;
34 import org.apache.derby.impl.jdbc.EmbedCallableStatement40;
35 import org.apache.derby.impl.jdbc.EmbedConnection40;
36 import org.apache.derby.impl.jdbc.EmbedResultSet;
37 import org.apache.derby.impl.jdbc.EmbedResultSet40;
38 import org.apache.derby.impl.jdbc.EmbedDatabaseMetaData40;
39 import org.apache.derby.impl.jdbc.SQLExceptionFactory40;
40 import org.apache.derby.impl.jdbc.EmbedStatement40;
41 import org.apache.derby.impl.jdbc.EmbedResultSetMetaData40;
42 import org.apache.derby.impl.jdbc.Util;
43 import java.sql.Connection JavaDoc;
44 import java.sql.SQLException JavaDoc;
45 import java.sql.CallableStatement JavaDoc;
46 import java.sql.PreparedStatement JavaDoc;
47 import java.util.Properties JavaDoc;
48 import org.apache.derby.iapi.sql.ResultColumnDescriptor;
49
50
51 public class Driver40 extends Driver30 {
52     
53     public Connection getNewNestedConnection(EmbedConnection conn) {
54         if (SanityManager.DEBUG) {
55             SanityManager.ASSERT(conn instanceof EmbedConnection30,
56                 "conn expected to be instanceof EmbedConnection30");
57         }
58         return new EmbedConnection40(conn);
59     }
60     
61     
62     public EmbedConnection getNewEmbedConnection(String JavaDoc url, Properties JavaDoc info)
63     throws SQLException JavaDoc {
64         return new EmbedConnection40(this, url, info);
65     }
66     
67     /**
68      * returns a new EmbedStatement
69      * @param conn the EmbedConnection class associated with
70      * this statement object
71      * @param forMetaData boolean
72      * @param resultSetType int
73      * @param resultSetConcurrency int
74      * @param resultSetHoldability int
75      * @return Statement a new java.sql.Statement implementation
76      *
77      */

78     public java.sql.Statement JavaDoc newEmbedStatement(
79                 EmbedConnection conn,
80                 boolean forMetaData,
81                 int resultSetType,
82                 int resultSetConcurrency,
83                 int resultSetHoldability)
84     {
85         return new EmbedStatement40(conn, forMetaData, resultSetType, resultSetConcurrency,
86         resultSetHoldability);
87     }
88     
89     public PreparedStatement JavaDoc
90         newEmbedPreparedStatement(
91         EmbedConnection conn,
92         String JavaDoc stmt,
93         boolean forMetaData,
94         int resultSetType,
95         int resultSetConcurrency,
96         int resultSetHoldability,
97         int autoGeneratedKeys,
98         int[] columnIndexes,
99         String JavaDoc[] columnNames)
100         throws SQLException JavaDoc {
101         return new EmbedPreparedStatement40(conn,
102             stmt,
103             forMetaData,
104             resultSetType,
105             resultSetConcurrency,
106             resultSetHoldability,
107             autoGeneratedKeys,
108             columnIndexes,
109             columnNames);
110     }
111     
112     
113     public CallableStatement JavaDoc newEmbedCallableStatement(
114         EmbedConnection conn,
115         String JavaDoc stmt,
116         int resultSetType,
117         int resultSetConcurrency,
118         int resultSetHoldability)
119         throws SQLException JavaDoc {
120         return new EmbedCallableStatement40(conn,
121             stmt,
122             resultSetType,
123             resultSetConcurrency,
124             resultSetHoldability);
125     }
126     public BrokeredConnection newBrokeredConnection(BrokeredConnectionControl control) {
127         
128         return new BrokeredConnection40(control);
129     }
130     
131     public EmbedResultSet newEmbedResultSet(EmbedConnection conn, ResultSet results, boolean forMetaData, org.apache.derby.impl.jdbc.EmbedStatement statement,boolean isAtomic) throws SQLException JavaDoc {
132         return new EmbedResultSet40(conn, results, forMetaData, statement,
133             isAtomic);
134     }
135     
136     /**
137      * Overwriting the super class boot method to set exception factory
138      * @see InternalDriver#boot
139      */

140
141     public void boot(boolean create, Properties JavaDoc properties)
142           throws StandardException {
143         Util.setExceptionFactory (new SQLExceptionFactory40 ());
144         super.boot (create, properties);
145     }
146
147     public DatabaseMetaData JavaDoc newEmbedDatabaseMetaData(EmbedConnection conn, String JavaDoc dbname)
148         throws SQLException JavaDoc {
149         return new EmbedDatabaseMetaData40(conn,dbname);
150     }
151     
152         /**
153          * Returns a new java.sql.ResultSetMetaData for this implementation
154          *
155          * @param columnInfo a ResultColumnDescriptor that stores information
156          * about the columns in a ResultSet
157          * @return ResultSetMetaData
158          */

159         public EmbedResultSetMetaData40 newEmbedResultSetMetaData
160                              (ResultColumnDescriptor[] columnInfo) {
161             return new EmbedResultSetMetaData40(columnInfo);
162         }
163 }
164
Popular Tags