KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  
3    Derby - Class org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40
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 org.apache.derby.client.ClientPooledConnection;
25 import org.apache.derby.client.ClientPooledConnection40;
26 import org.apache.derby.client.am.CallableStatement;
27 import org.apache.derby.client.am.CallableStatement40;
28 import org.apache.derby.client.am.ColumnMetaData;
29 import org.apache.derby.client.am.ColumnMetaData40;
30 import org.apache.derby.client.am.ClientJDBCObjectFactory;
31 import org.apache.derby.client.am.LogicalConnection;
32 import org.apache.derby.client.am.LogicalConnection40;
33 import org.apache.derby.client.am.PreparedStatement;
34 import org.apache.derby.client.am.PreparedStatement40;
35 import org.apache.derby.client.am.ParameterMetaData;
36 import org.apache.derby.client.am.ParameterMetaData40;
37 import org.apache.derby.client.am.LogWriter;
38 import org.apache.derby.client.am.Agent;
39 import org.apache.derby.client.am.SQLExceptionFactory40;
40 import org.apache.derby.client.am.Section;
41 import org.apache.derby.client.am.Statement;
42 import org.apache.derby.client.am.Statement40;
43 import org.apache.derby.client.am.SqlException;
44 import org.apache.derby.client.am.Cursor;
45 import org.apache.derby.jdbc.ClientDataSource;
46 import java.sql.SQLException JavaDoc;
47 import org.apache.derby.jdbc.ClientBaseDataSource;
48
49 /**
50  * Implements the ClientJDBCObjectFactory interface
51  * and returns the JDBC4.0 specific classes
52  */

53 public class ClientJDBCObjectFactoryImpl40 implements ClientJDBCObjectFactory{
54     
55     /**
56      * Sets SQLExceptionFactpry40 om SqlException to make sure jdbc40
57      * exception and sub classes are thrown when running with jdbc4.0 support
58      */

59     public ClientJDBCObjectFactoryImpl40 () {
60         SqlException.setExceptionFactory (new SQLExceptionFactory40 ());
61     }
62     /**
63      * Returns an instance of org.apache.derby.client.ClientPooledConnection40
64      */

65     public ClientPooledConnection newClientPooledConnection(
66             ClientBaseDataSource ds, LogWriter logWriter,String JavaDoc user,
67             String JavaDoc password) throws SQLException JavaDoc {
68         return new ClientPooledConnection40(ds,logWriter,user,password);
69     }
70     /**
71      * Returns an instance of org.apache.derby.client.ClientPooledConnection40
72      */

73     public ClientPooledConnection newClientPooledConnection(
74             ClientBaseDataSource ds, LogWriter logWriter,String JavaDoc user,
75             String JavaDoc password,int rmId) throws SQLException JavaDoc {
76         return new ClientPooledConnection40(ds,logWriter,user,password,rmId);
77     }
78     /**
79      * Returns an instance of org.apache.derby.client.am.CallableStatement.
80      *
81      * @param agent The instance of NetAgent associated with this
82      * CallableStatement object.
83      * @param connection The connection object associated with this
84      * PreparedStatement Object.
85      * @param sql A String object that is the SQL statement to be sent
86      * to the database.
87      * @param type One of the ResultSet type constants
88      * @param concurrency One of the ResultSet concurrency constants
89      * @param holdability One of the ResultSet holdability constants
90      * @param cpc The PooledConnection object that will be used to
91      * notify the PooledConnection reference of the Error
92      * Occurred and the Close events.
93      * @return a CallableStatement object
94      * @throws SqlException
95      */

96     public CallableStatement newCallableStatement(Agent agent,
97             org.apache.derby.client.am.Connection connection,
98             String JavaDoc sql,int type,int concurrency,
99             int holdability,ClientPooledConnection cpc) throws SqlException {
100         return new CallableStatement40(agent,connection,sql,type,concurrency,
101                 holdability,cpc);
102     }
103     /**
104      * Returns an instance of LogicalConnection.
105      * This method returns an instance of LogicalConnection
106      * (or LogicalConnection40) which implements java.sql.Connection.
107      */

108     public LogicalConnection newLogicalConnection(
109                     org.apache.derby.client.am.Connection physicalConnection,
110                     ClientPooledConnection pooledConnection)
111         throws SqlException {
112         return new LogicalConnection40(physicalConnection, pooledConnection);
113     }
114     
115     /**
116      * Returns an instance of org.apache.derby.client.am.CallableStatement40
117      */

118     public PreparedStatement newPreparedStatement(Agent agent,
119             org.apache.derby.client.am.Connection connection,
120             String JavaDoc sql,Section section,ClientPooledConnection cpc)
121             throws SqlException {
122         return new PreparedStatement40(agent,connection,sql,section,cpc);
123     }
124     
125     /**
126      *
127      * This method returns an instance of PreparedStatement
128      * which implements java.sql.PreparedStatement.
129      * It has the ClientPooledConnection as one of its parameters
130      * this is used to raise the Statement Events when the prepared
131      * statement is closed.
132      *
133      * @param agent The instance of NetAgent associated with this
134      * CallableStatement object.
135      * @param connection The connection object associated with this
136      * PreparedStatement Object.
137      * @param sql A String object that is the SQL statement
138      * to be sent to the database.
139      * @param type One of the ResultSet type constants.
140      * @param concurrency One of the ResultSet concurrency constants.
141      * @param holdability One of the ResultSet holdability constants.
142      * @param autoGeneratedKeys a flag indicating whether auto-generated
143      * keys should be returned.
144      * @param columnNames an array of column names indicating the columns that
145      * should be returned from the inserted row or rows.
146      * @param cpc The ClientPooledConnection wraps the underlying physical
147      * connection associated with this prepared statement
148      * it is used to pass the Statement closed and the Statement
149      * error occurred events that occur back to the
150      * ClientPooledConnection.
151      * @return a PreparedStatement object
152      * @throws SqlException
153      *
154      */

155     public PreparedStatement newPreparedStatement(Agent agent,
156             org.apache.derby.client.am.Connection connection,
157             String JavaDoc sql,int type,int concurrency,
158             int holdability,int autoGeneratedKeys,
159             String JavaDoc [] columnNames,ClientPooledConnection cpc)
160             throws SqlException {
161         return new PreparedStatement40(agent,connection,sql,type,concurrency,
162                 holdability,autoGeneratedKeys,columnNames,cpc);
163     }
164
165     
166     /**
167      * returns an instance of org.apache.derby.client.net.NetConnection40
168      */

169     public org.apache.derby.client.am.Connection newNetConnection
170             (org.apache.derby.client.am.LogWriter netLogWriter,
171             String JavaDoc databaseName,java.util.Properties JavaDoc properties)
172             throws SqlException {
173         return (org.apache.derby.client.am.Connection)
174         (new NetConnection40((NetLogWriter)netLogWriter,databaseName,properties));
175     }
176     /**
177      * returns an instance of org.apache.derby.client.net.NetConnection40
178      */

179     public org.apache.derby.client.am.Connection newNetConnection
180             (org.apache.derby.client.am.LogWriter netLogWriter,
181             org.apache.derby.jdbc.ClientBaseDataSource clientDataSource,
182             String JavaDoc user,String JavaDoc password) throws SqlException {
183         return (org.apache.derby.client.am.Connection)
184         (new NetConnection40((NetLogWriter)netLogWriter,clientDataSource,user,password));
185     }
186     /**
187      * returns an instance of org.apache.derby.client.net.NetConnection40
188      */

189     public org.apache.derby.client.am.Connection
190             newNetConnection(org.apache.derby.client.am.LogWriter netLogWriter,
191             int driverManagerLoginTimeout,String JavaDoc serverName,
192             int portNumber,String JavaDoc databaseName,
193             java.util.Properties JavaDoc properties) throws SqlException {
194         return (org.apache.derby.client.am.Connection)
195         (new NetConnection40((NetLogWriter)netLogWriter,driverManagerLoginTimeout,
196                 serverName,portNumber,databaseName,properties));
197     }
198     /**
199      * returns an instance of org.apache.derby.client.net.NetConnection40
200      */

201     public org.apache.derby.client.am.Connection
202             newNetConnection(org.apache.derby.client.am.LogWriter netLogWriter,
203             String JavaDoc user,
204             String JavaDoc password,
205             org.apache.derby.jdbc.ClientBaseDataSource dataSource,
206             int rmId,boolean isXAConn) throws SqlException {
207         return (org.apache.derby.client.am.Connection)
208         (new NetConnection40((NetLogWriter)netLogWriter,user,password,dataSource,
209                 rmId,isXAConn));
210     }
211     /**
212      * returns an instance of org.apache.derby.client.net.NetConnection40
213      */

214     public org.apache.derby.client.am.Connection
215             newNetConnection(org.apache.derby.client.am.LogWriter netLogWriter,
216             String JavaDoc ipaddr,int portNumber,
217             org.apache.derby.jdbc.ClientBaseDataSource dataSource,
218             boolean isXAConn) throws SqlException {
219         return (org.apache.derby.client.am.Connection)
220         (new NetConnection40((NetLogWriter)netLogWriter,ipaddr,portNumber,dataSource,
221                 isXAConn));
222     }
223     /**
224      * Returns an instance of org.apache.derby.client.net.NetConnection.
225      * @param netLogWriter placeholder for NetLogWriter object associated with this connection
226      * @param user user id for this connection
227      * @param password password for this connection
228      * @param dataSource The DataSource object passed from the PooledConnection
229      * object from which this constructor was called
230      * @param rmId The Resource Manager ID for XA Connections
231      * @param isXAConn true if this is a XA connection
232      * @param cpc The ClientPooledConnection object from which this
233      * NetConnection constructor was called. This is used
234      * to pass StatementEvents back to the pooledConnection
235      * object
236      * @return a org.apache.derby.client.am.Connection object
237      * @throws SqlException
238      */

239     public org.apache.derby.client.am.Connection newNetConnection(
240             org.apache.derby.client.am.LogWriter netLogWriter,String JavaDoc user,
241             String JavaDoc password,
242             org.apache.derby.jdbc.ClientBaseDataSource dataSource,
243             int rmId,boolean isXAConn,ClientPooledConnection cpc)
244             throws SqlException {
245         return (org.apache.derby.client.am.Connection)
246         (new NetConnection40((NetLogWriter)netLogWriter,user,password,dataSource,rmId,
247                 isXAConn,cpc));
248         
249     }
250     /**
251      * returns an instance of org.apache.derby.client.net.NetResultSet
252      */

253     public org.apache.derby.client.am.ResultSet newNetResultSet(Agent netAgent,
254             org.apache.derby.client.am.MaterialStatement netStatement,
255             Cursor cursor,int qryprctyp,int sqlcsrhld,
256             int qryattscr,int qryattsns,int qryattset,long qryinsid,
257             int actualResultSetType,int actualResultSetConcurrency,
258             int actualResultSetHoldability) throws SqlException {
259         return new NetResultSet40((NetAgent)netAgent,(NetStatement)netStatement,
260                 cursor,
261                 qryprctyp, sqlcsrhld, qryattscr, qryattsns, qryattset, qryinsid,
262                 actualResultSetType,actualResultSetConcurrency,
263                 actualResultSetHoldability);
264     }
265     /**
266      * returns an instance of org.apache.derby.client.net.NetDatabaseMetaData
267      */

268     public org.apache.derby.client.am.DatabaseMetaData newNetDatabaseMetaData(Agent netAgent,
269             org.apache.derby.client.am.Connection netConnection) {
270         return new NetDatabaseMetaData40((NetAgent)netAgent,
271                 (NetConnection)netConnection);
272     }
273     
274      /**
275      * This method provides an instance of Statement40
276      * @param agent Agent
277      * @param connection Connection
278      * @return a java.sql.Statement implementation
279      * @throws SqlException
280      *
281      */

282      public Statement newStatement(Agent agent, org.apache.derby.client.am.Connection connection)
283                                             throws SqlException {
284          return new Statement40(agent,connection);
285      }
286      
287      /**
288      * This method provides an instance of Statement40
289      * @param agent Agent
290      * @param connection Connection
291      * @param type int
292      * @param concurrency int
293      * @param holdability int
294      * @param autoGeneratedKeys int
295      * @param columnNames String[]
296      * @return a java.sql.Statement implementation
297      * @throws SqlException
298      *
299      */

300      public Statement newStatement(Agent agent,
301                      org.apache.derby.client.am.Connection connection, int type,
302                      int concurrency, int holdability,
303                      int autoGeneratedKeys, String JavaDoc[] columnNames)
304                      throws SqlException {
305          return new Statement40(agent,connection,type,concurrency,holdability,
306                  autoGeneratedKeys,columnNames);
307      }
308      
309      /**
310      * Returns an instanceof ColumnMetaData
311      *
312      * @param logWriter LogWriter
313      * @return a ColumnMetaData implementation
314      *
315      */

316     public ColumnMetaData newColumnMetaData(LogWriter logWriter) {
317         return new ColumnMetaData40(logWriter);
318     }
319
320     /**
321      * Returns an instanceof ColumnMetaData or ColumnMetaData40 depending
322      * on the jdk version under use
323      *
324      * @param logWriter LogWriter
325      * @param upperBound int
326      * @return a ColumnMetaData implementation
327      *
328      */

329     public ColumnMetaData newColumnMetaData(LogWriter logWriter, int upperBound) {
330         return new ColumnMetaData40(logWriter,upperBound);
331     }
332     
333     /**
334      *
335      * returns an instance of ParameterMetaData40
336      *
337      * @param columnMetaData ColumnMetaData
338      * @return a ParameterMetaData implementation
339      *
340      */

341     public ParameterMetaData newParameterMetaData(ColumnMetaData columnMetaData) {
342         return new ParameterMetaData40(columnMetaData);
343     }
344 }
345
Popular Tags