001: /*
002:
003: Derby - Class org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to You under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.client.net;
023:
024: import org.apache.derby.client.ClientPooledConnection;
025: import org.apache.derby.client.ClientPooledConnection40;
026: import org.apache.derby.client.am.CallableStatement;
027: import org.apache.derby.client.am.CallableStatement40;
028: import org.apache.derby.client.am.ColumnMetaData;
029: import org.apache.derby.client.am.ColumnMetaData40;
030: import org.apache.derby.client.am.ClientJDBCObjectFactory;
031: import org.apache.derby.client.am.LogicalConnection;
032: import org.apache.derby.client.am.LogicalConnection40;
033: import org.apache.derby.client.am.PreparedStatement;
034: import org.apache.derby.client.am.PreparedStatement40;
035: import org.apache.derby.client.am.ParameterMetaData;
036: import org.apache.derby.client.am.ParameterMetaData40;
037: import org.apache.derby.client.am.LogWriter;
038: import org.apache.derby.client.am.Agent;
039: import org.apache.derby.client.am.SQLExceptionFactory40;
040: import org.apache.derby.client.am.Section;
041: import org.apache.derby.client.am.Statement;
042: import org.apache.derby.client.am.Statement40;
043: import org.apache.derby.client.am.SqlException;
044: import org.apache.derby.client.am.Cursor;
045: import org.apache.derby.jdbc.ClientDataSource;
046: import java.sql.SQLException;
047: import org.apache.derby.jdbc.ClientBaseDataSource;
048:
049: /**
050: * Implements the ClientJDBCObjectFactory interface
051: * and returns the JDBC4.0 specific classes
052: */
053: public class ClientJDBCObjectFactoryImpl40 implements
054: ClientJDBCObjectFactory {
055:
056: /**
057: * Sets SQLExceptionFactpry40 om SqlException to make sure jdbc40
058: * exception and sub classes are thrown when running with jdbc4.0 support
059: */
060: public ClientJDBCObjectFactoryImpl40() {
061: SqlException.setExceptionFactory(new SQLExceptionFactory40());
062: }
063:
064: /**
065: * Returns an instance of org.apache.derby.client.ClientPooledConnection40
066: */
067: public ClientPooledConnection newClientPooledConnection(
068: ClientBaseDataSource ds, LogWriter logWriter, String user,
069: String password) throws SQLException {
070: return new ClientPooledConnection40(ds, logWriter, user,
071: password);
072: }
073:
074: /**
075: * Returns an instance of org.apache.derby.client.ClientPooledConnection40
076: */
077: public ClientPooledConnection newClientPooledConnection(
078: ClientBaseDataSource ds, LogWriter logWriter, String user,
079: String password, int rmId) throws SQLException {
080: return new ClientPooledConnection40(ds, logWriter, user,
081: password, rmId);
082: }
083:
084: /**
085: * Returns an instance of org.apache.derby.client.am.CallableStatement.
086: *
087: * @param agent The instance of NetAgent associated with this
088: * CallableStatement object.
089: * @param connection The connection object associated with this
090: * PreparedStatement Object.
091: * @param sql A String object that is the SQL statement to be sent
092: * to the database.
093: * @param type One of the ResultSet type constants
094: * @param concurrency One of the ResultSet concurrency constants
095: * @param holdability One of the ResultSet holdability constants
096: * @param cpc The PooledConnection object that will be used to
097: * notify the PooledConnection reference of the Error
098: * Occurred and the Close events.
099: * @return a CallableStatement object
100: * @throws SqlException
101: */
102: public CallableStatement newCallableStatement(Agent agent,
103: org.apache.derby.client.am.Connection connection,
104: String sql, int type, int concurrency, int holdability,
105: ClientPooledConnection cpc) throws SqlException {
106: return new CallableStatement40(agent, connection, sql, type,
107: concurrency, holdability, cpc);
108: }
109:
110: /**
111: * Returns an instance of LogicalConnection.
112: * This method returns an instance of LogicalConnection
113: * (or LogicalConnection40) which implements java.sql.Connection.
114: */
115: public LogicalConnection newLogicalConnection(
116: org.apache.derby.client.am.Connection physicalConnection,
117: ClientPooledConnection pooledConnection)
118: throws SqlException {
119: return new LogicalConnection40(physicalConnection,
120: pooledConnection);
121: }
122:
123: /**
124: * Returns an instance of org.apache.derby.client.am.CallableStatement40
125: */
126: public PreparedStatement newPreparedStatement(Agent agent,
127: org.apache.derby.client.am.Connection connection,
128: String sql, Section section, ClientPooledConnection cpc)
129: throws SqlException {
130: return new PreparedStatement40(agent, connection, sql, section,
131: cpc);
132: }
133:
134: /**
135: *
136: * This method returns an instance of PreparedStatement
137: * which implements java.sql.PreparedStatement.
138: * It has the ClientPooledConnection as one of its parameters
139: * this is used to raise the Statement Events when the prepared
140: * statement is closed.
141: *
142: * @param agent The instance of NetAgent associated with this
143: * CallableStatement object.
144: * @param connection The connection object associated with this
145: * PreparedStatement Object.
146: * @param sql A String object that is the SQL statement
147: * to be sent to the database.
148: * @param type One of the ResultSet type constants.
149: * @param concurrency One of the ResultSet concurrency constants.
150: * @param holdability One of the ResultSet holdability constants.
151: * @param autoGeneratedKeys a flag indicating whether auto-generated
152: * keys should be returned.
153: * @param columnNames an array of column names indicating the columns that
154: * should be returned from the inserted row or rows.
155: * @param cpc The ClientPooledConnection wraps the underlying physical
156: * connection associated with this prepared statement
157: * it is used to pass the Statement closed and the Statement
158: * error occurred events that occur back to the
159: * ClientPooledConnection.
160: * @return a PreparedStatement object
161: * @throws SqlException
162: *
163: */
164: public PreparedStatement newPreparedStatement(Agent agent,
165: org.apache.derby.client.am.Connection connection,
166: String sql, int type, int concurrency, int holdability,
167: int autoGeneratedKeys, String[] columnNames,
168: ClientPooledConnection cpc) throws SqlException {
169: return new PreparedStatement40(agent, connection, sql, type,
170: concurrency, holdability, autoGeneratedKeys,
171: columnNames, cpc);
172: }
173:
174: /**
175: * returns an instance of org.apache.derby.client.net.NetConnection40
176: */
177: public org.apache.derby.client.am.Connection newNetConnection(
178: org.apache.derby.client.am.LogWriter netLogWriter,
179: String databaseName, java.util.Properties properties)
180: throws SqlException {
181: return (org.apache.derby.client.am.Connection) (new NetConnection40(
182: (NetLogWriter) netLogWriter, databaseName, properties));
183: }
184:
185: /**
186: * returns an instance of org.apache.derby.client.net.NetConnection40
187: */
188: public org.apache.derby.client.am.Connection newNetConnection(
189: org.apache.derby.client.am.LogWriter netLogWriter,
190: org.apache.derby.jdbc.ClientBaseDataSource clientDataSource,
191: String user, String password) throws SqlException {
192: return (org.apache.derby.client.am.Connection) (new NetConnection40(
193: (NetLogWriter) netLogWriter, clientDataSource, user,
194: password));
195: }
196:
197: /**
198: * returns an instance of org.apache.derby.client.net.NetConnection40
199: */
200: public org.apache.derby.client.am.Connection newNetConnection(
201: org.apache.derby.client.am.LogWriter netLogWriter,
202: int driverManagerLoginTimeout, String serverName,
203: int portNumber, String databaseName,
204: java.util.Properties properties) throws SqlException {
205: return (org.apache.derby.client.am.Connection) (new NetConnection40(
206: (NetLogWriter) netLogWriter, driverManagerLoginTimeout,
207: serverName, portNumber, databaseName, properties));
208: }
209:
210: /**
211: * returns an instance of org.apache.derby.client.net.NetConnection40
212: */
213: public org.apache.derby.client.am.Connection newNetConnection(
214: org.apache.derby.client.am.LogWriter netLogWriter,
215: String user, String password,
216: org.apache.derby.jdbc.ClientBaseDataSource dataSource,
217: int rmId, boolean isXAConn) throws SqlException {
218: return (org.apache.derby.client.am.Connection) (new NetConnection40(
219: (NetLogWriter) netLogWriter, user, password,
220: dataSource, rmId, isXAConn));
221: }
222:
223: /**
224: * returns an instance of org.apache.derby.client.net.NetConnection40
225: */
226: public org.apache.derby.client.am.Connection newNetConnection(
227: org.apache.derby.client.am.LogWriter netLogWriter,
228: String ipaddr, int portNumber,
229: org.apache.derby.jdbc.ClientBaseDataSource dataSource,
230: boolean isXAConn) throws SqlException {
231: return (org.apache.derby.client.am.Connection) (new NetConnection40(
232: (NetLogWriter) netLogWriter, ipaddr, portNumber,
233: dataSource, isXAConn));
234: }
235:
236: /**
237: * Returns an instance of org.apache.derby.client.net.NetConnection.
238: * @param netLogWriter placeholder for NetLogWriter object associated with this connection
239: * @param user user id for this connection
240: * @param password password for this connection
241: * @param dataSource The DataSource object passed from the PooledConnection
242: * object from which this constructor was called
243: * @param rmId The Resource Manager ID for XA Connections
244: * @param isXAConn true if this is a XA connection
245: * @param cpc The ClientPooledConnection object from which this
246: * NetConnection constructor was called. This is used
247: * to pass StatementEvents back to the pooledConnection
248: * object
249: * @return a org.apache.derby.client.am.Connection object
250: * @throws SqlException
251: */
252: public org.apache.derby.client.am.Connection newNetConnection(
253: org.apache.derby.client.am.LogWriter netLogWriter,
254: String user, String password,
255: org.apache.derby.jdbc.ClientBaseDataSource dataSource,
256: int rmId, boolean isXAConn, ClientPooledConnection cpc)
257: throws SqlException {
258: return (org.apache.derby.client.am.Connection) (new NetConnection40(
259: (NetLogWriter) netLogWriter, user, password,
260: dataSource, rmId, isXAConn, cpc));
261:
262: }
263:
264: /**
265: * returns an instance of org.apache.derby.client.net.NetResultSet
266: */
267: public org.apache.derby.client.am.ResultSet newNetResultSet(
268: Agent netAgent,
269: org.apache.derby.client.am.MaterialStatement netStatement,
270: Cursor cursor, int qryprctyp, int sqlcsrhld, int qryattscr,
271: int qryattsns, int qryattset, long qryinsid,
272: int actualResultSetType, int actualResultSetConcurrency,
273: int actualResultSetHoldability) throws SqlException {
274: return new NetResultSet40((NetAgent) netAgent,
275: (NetStatement) netStatement, cursor, qryprctyp,
276: sqlcsrhld, qryattscr, qryattsns, qryattset, qryinsid,
277: actualResultSetType, actualResultSetConcurrency,
278: actualResultSetHoldability);
279: }
280:
281: /**
282: * returns an instance of org.apache.derby.client.net.NetDatabaseMetaData
283: */
284: public org.apache.derby.client.am.DatabaseMetaData newNetDatabaseMetaData(
285: Agent netAgent,
286: org.apache.derby.client.am.Connection netConnection) {
287: return new NetDatabaseMetaData40((NetAgent) netAgent,
288: (NetConnection) netConnection);
289: }
290:
291: /**
292: * This method provides an instance of Statement40
293: * @param agent Agent
294: * @param connection Connection
295: * @return a java.sql.Statement implementation
296: * @throws SqlException
297: *
298: */
299: public Statement newStatement(Agent agent,
300: org.apache.derby.client.am.Connection connection)
301: throws SqlException {
302: return new Statement40(agent, connection);
303: }
304:
305: /**
306: * This method provides an instance of Statement40
307: * @param agent Agent
308: * @param connection Connection
309: * @param type int
310: * @param concurrency int
311: * @param holdability int
312: * @param autoGeneratedKeys int
313: * @param columnNames String[]
314: * @return a java.sql.Statement implementation
315: * @throws SqlException
316: *
317: */
318: public Statement newStatement(Agent agent,
319: org.apache.derby.client.am.Connection connection, int type,
320: int concurrency, int holdability, int autoGeneratedKeys,
321: String[] columnNames) throws SqlException {
322: return new Statement40(agent, connection, type, concurrency,
323: holdability, autoGeneratedKeys, columnNames);
324: }
325:
326: /**
327: * Returns an instanceof ColumnMetaData
328: *
329: * @param logWriter LogWriter
330: * @return a ColumnMetaData implementation
331: *
332: */
333: public ColumnMetaData newColumnMetaData(LogWriter logWriter) {
334: return new ColumnMetaData40(logWriter);
335: }
336:
337: /**
338: * Returns an instanceof ColumnMetaData or ColumnMetaData40 depending
339: * on the jdk version under use
340: *
341: * @param logWriter LogWriter
342: * @param upperBound int
343: * @return a ColumnMetaData implementation
344: *
345: */
346: public ColumnMetaData newColumnMetaData(LogWriter logWriter,
347: int upperBound) {
348: return new ColumnMetaData40(logWriter, upperBound);
349: }
350:
351: /**
352: *
353: * returns an instance of ParameterMetaData40
354: *
355: * @param columnMetaData ColumnMetaData
356: * @return a ParameterMetaData implementation
357: *
358: */
359: public ParameterMetaData newParameterMetaData(
360: ColumnMetaData columnMetaData) {
361: return new ParameterMetaData40(columnMetaData);
362: }
363: }
|