/projects/derby-10.9.1.0/db-derby-10.9.1.0-src/java/engine/org/apache/derby/jdbc/Driver40.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus · Java · 208 lines · 130 code · 22 blank · 56 comment · 1 complexity · 10121ea83f2933004b5467e34901b2d4 MD5 · raw file

  1. /*
  2. Derby - Class org.apache.derby.jdbc.Driver40
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. */
  16. package org.apache.derby.jdbc;
  17. import java.sql.DatabaseMetaData;
  18. import org.apache.derby.iapi.jdbc.BrokeredConnection;
  19. import org.apache.derby.iapi.jdbc.BrokeredConnectionControl;
  20. import org.apache.derby.iapi.jdbc.BrokeredConnection40;
  21. import org.apache.derby.iapi.sql.ResultSet;
  22. import org.apache.derby.iapi.services.sanity.SanityManager;
  23. import org.apache.derby.iapi.error.StandardException;
  24. import org.apache.derby.impl.jdbc.EmbedConnection;
  25. import org.apache.derby.impl.jdbc.EmbedConnection30;
  26. import org.apache.derby.impl.jdbc.EmbedPreparedStatement40;
  27. import org.apache.derby.impl.jdbc.EmbedCallableStatement40;
  28. import org.apache.derby.impl.jdbc.EmbedConnection40;
  29. import org.apache.derby.impl.jdbc.EmbedResultSet;
  30. import org.apache.derby.impl.jdbc.EmbedResultSet40;
  31. import org.apache.derby.impl.jdbc.EmbedDatabaseMetaData40;
  32. import org.apache.derby.impl.jdbc.SQLExceptionFactory40;
  33. import org.apache.derby.impl.jdbc.EmbedStatement40;
  34. import org.apache.derby.impl.jdbc.EmbedResultSetMetaData40;
  35. import org.apache.derby.iapi.jdbc.ResourceAdapter;
  36. import org.apache.derby.impl.jdbc.Util;
  37. import java.sql.Connection;
  38. import java.sql.SQLException;
  39. import java.sql.CallableStatement;
  40. import java.sql.PreparedStatement;
  41. import java.sql.SQLFeatureNotSupportedException;
  42. import java.util.Properties;
  43. import java.util.logging.Logger;
  44. import org.apache.derby.iapi.sql.ResultColumnDescriptor;
  45. /** -- jdbc 2.0. extension -- */
  46. import javax.sql.PooledConnection;
  47. import javax.sql.XAConnection;
  48. public class Driver40 extends Driver30 {
  49. public Connection getNewNestedConnection(EmbedConnection conn) {
  50. if (SanityManager.DEBUG) {
  51. SanityManager.ASSERT(conn instanceof EmbedConnection30,
  52. "conn expected to be instanceof EmbedConnection30");
  53. }
  54. return new EmbedConnection40(conn);
  55. }
  56. protected EmbedConnection getNewEmbedConnection(String url, Properties info)
  57. throws SQLException {
  58. return new EmbedConnection40(this, url, info);
  59. }
  60. /**
  61. * returns a new EmbedStatement
  62. * @param conn the EmbedConnection class associated with
  63. * this statement object
  64. * @param forMetaData boolean
  65. * @param resultSetType int
  66. * @param resultSetConcurrency int
  67. * @param resultSetHoldability int
  68. * @return Statement a new java.sql.Statement implementation
  69. *
  70. */
  71. public java.sql.Statement newEmbedStatement(
  72. EmbedConnection conn,
  73. boolean forMetaData,
  74. int resultSetType,
  75. int resultSetConcurrency,
  76. int resultSetHoldability)
  77. {
  78. return new EmbedStatement40(conn, forMetaData, resultSetType, resultSetConcurrency,
  79. resultSetHoldability);
  80. }
  81. public PreparedStatement
  82. newEmbedPreparedStatement(
  83. EmbedConnection conn,
  84. String stmt,
  85. boolean forMetaData,
  86. int resultSetType,
  87. int resultSetConcurrency,
  88. int resultSetHoldability,
  89. int autoGeneratedKeys,
  90. int[] columnIndexes,
  91. String[] columnNames)
  92. throws SQLException {
  93. return new EmbedPreparedStatement40(conn,
  94. stmt,
  95. forMetaData,
  96. resultSetType,
  97. resultSetConcurrency,
  98. resultSetHoldability,
  99. autoGeneratedKeys,
  100. columnIndexes,
  101. columnNames);
  102. }
  103. public CallableStatement newEmbedCallableStatement(
  104. EmbedConnection conn,
  105. String stmt,
  106. int resultSetType,
  107. int resultSetConcurrency,
  108. int resultSetHoldability)
  109. throws SQLException {
  110. return new EmbedCallableStatement40(conn,
  111. stmt,
  112. resultSetType,
  113. resultSetConcurrency,
  114. resultSetHoldability);
  115. }
  116. public BrokeredConnection newBrokeredConnection(
  117. BrokeredConnectionControl control) throws SQLException {
  118. return new BrokeredConnection40(control);
  119. }
  120. public EmbedResultSet newEmbedResultSet(EmbedConnection conn, ResultSet results, boolean forMetaData, org.apache.derby.impl.jdbc.EmbedStatement statement,boolean isAtomic) throws SQLException {
  121. return new EmbedResultSet40(conn, results, forMetaData, statement,
  122. isAtomic);
  123. }
  124. /**
  125. * Overwriting the super class boot method to set exception factory
  126. * @see InternalDriver#boot
  127. */
  128. public void boot(boolean create, Properties properties)
  129. throws StandardException {
  130. Util.setExceptionFactory (new SQLExceptionFactory40 ());
  131. super.boot (create, properties);
  132. }
  133. public DatabaseMetaData newEmbedDatabaseMetaData(EmbedConnection conn, String dbname)
  134. throws SQLException {
  135. return new EmbedDatabaseMetaData40(conn,dbname);
  136. }
  137. /**
  138. * Returns a new java.sql.ResultSetMetaData for this implementation
  139. *
  140. * @param columnInfo a ResultColumnDescriptor that stores information
  141. * about the columns in a ResultSet
  142. * @return ResultSetMetaData
  143. */
  144. public EmbedResultSetMetaData40 newEmbedResultSetMetaData
  145. (ResultColumnDescriptor[] columnInfo) {
  146. return new EmbedResultSetMetaData40(columnInfo);
  147. }
  148. /**
  149. * Create and return an EmbedPooledConnection from the received instance
  150. * of EmbeddedDataSource.
  151. */
  152. protected PooledConnection getNewPooledConnection(
  153. EmbeddedDataSource eds, String user, String password,
  154. boolean requestPassword) throws SQLException
  155. {
  156. return new EmbedPooledConnection40(
  157. eds, user, password, requestPassword);
  158. }
  159. /**
  160. * Create and return an EmbedXAConnection from the received instance
  161. * of EmbeddedDataSource.
  162. */
  163. protected XAConnection getNewXAConnection(
  164. EmbeddedDataSource eds, ResourceAdapter ra,
  165. String user, String password, boolean requestPassword)
  166. throws SQLException
  167. {
  168. return new EmbedXAConnection40(
  169. eds, ra, user, password, requestPassword);
  170. }
  171. ////////////////////////////////////////////////////////////////////
  172. //
  173. // INTRODUCED BY JDBC 4.1 IN JAVA 7
  174. //
  175. ////////////////////////////////////////////////////////////////////
  176. public Logger getParentLogger()
  177. throws SQLFeatureNotSupportedException
  178. {
  179. throw (SQLFeatureNotSupportedException) Util.notImplemented( "getParentLogger()" );
  180. }
  181. }