1 21 22 package org.apache.derby.iapi.jdbc; 23 24 import java.sql.Array ; 25 import java.sql.Blob ; 26 import java.sql.Clob ; 27 import java.sql.Connection ; 28 import java.sql.SQLClientInfoException ; 29 import java.sql.NClob ; 30 import java.sql.SQLException ; 31 import java.sql.SQLXML ; 32 import java.sql.Struct ; 33 import java.util.Properties ; 34 import org.apache.derby.impl.jdbc.Util; 35 import org.apache.derby.iapi.reference.SQLState; 37 38 39 public class BrokeredConnection40 extends BrokeredConnection30 { 40 41 42 public BrokeredConnection40(BrokeredConnectionControl control) { 43 super(control); 44 } 45 46 public Array createArrayOf(String typeName, Object [] elements) 47 throws SQLException { 48 try { 49 return getRealConnection().createArrayOf (typeName, elements); 50 } catch (SQLException sqle) { 51 notifyException(sqle); 52 throw sqle; 53 } 54 } 55 56 69 public Blob createBlob() throws SQLException { 70 if (isClosed()) { 71 throw Util.noCurrentConnection(); 72 } 73 try { 75 return getRealConnection().createBlob(); 76 } catch (SQLException sqle) { 77 notifyException(sqle); 78 throw sqle; 79 } 80 } 81 82 95 public Clob createClob() throws SQLException { 96 if (isClosed()) { 97 throw Util.noCurrentConnection(); 98 } 99 try { 101 return getRealConnection().createClob(); 102 } catch (SQLException sqle) { 103 notifyException(sqle); 104 throw sqle; 105 } 106 } 107 108 109 public NClob createNClob() throws SQLException { 110 try { 111 return getRealConnection().createNClob(); 112 } catch (SQLException sqle) { 113 notifyException(sqle); 114 throw sqle; 115 } 116 } 117 118 public SQLXML createSQLXML() throws SQLException { 119 try { 120 return getRealConnection().createSQLXML (); 121 } catch (SQLException sqle) { 122 notifyException(sqle); 123 throw sqle; 124 } 125 } 126 127 public Struct createStruct(String typeName, Object [] attributes) 128 throws SQLException { 129 try { 130 return getRealConnection().createStruct (typeName, attributes); 131 } catch (SQLException sqle) { 132 notifyException(sqle); 133 throw sqle; 134 } 135 } 136 137 138 152 public final boolean isValid(int timeout) throws SQLException { 153 if (isClosed()) { 155 return false; 156 } 157 158 try { 160 return getRealConnection().isValid(timeout); 161 } catch (SQLException sqle) { 162 notifyException(sqle); 163 throw sqle; 164 } 165 } 166 167 168 176 public void setClientInfo(String name, String value) 177 throws SQLClientInfoException { 178 try { 179 getRealConnection().setClientInfo(name, value); 180 } catch (SQLClientInfoException se) { 181 notifyException(se); 182 throw se; 183 } 184 catch (SQLException se) { 185 throw new SQLClientInfoException 186 (se.getMessage(), se.getSQLState(), 187 (new FailedProperties40 188 (FailedProperties40.makeProperties(name,value))). 189 getProperties()); 190 } 191 } 192 193 204 public void setClientInfo(Properties properties) 205 throws SQLClientInfoException { 206 try { 207 getRealConnection().setClientInfo(properties); 208 } catch (SQLClientInfoException cie) { 209 notifyException(cie); 210 throw cie; 211 } 212 catch (SQLException se) { 213 throw new SQLClientInfoException 214 (se.getMessage(), se.getSQLState(), 215 (new FailedProperties40(properties)).getProperties()); 216 } 217 } 218 219 226 public String getClientInfo(String name) 227 throws SQLException { 228 try { 229 return getRealConnection().getClientInfo(name); 230 } catch (SQLException se) { 231 notifyException(se); 232 throw se; 233 } 234 } 235 236 243 public Properties getClientInfo() 244 throws SQLException { 245 try { 246 return getRealConnection().getClientInfo(); 247 } catch (SQLException se) { 248 notifyException(se); 249 throw se; 250 } 251 } 252 253 259 public final BrokeredStatement newBrokeredStatement 260 (BrokeredStatementControl statementControl) throws SQLException { 261 try { 262 return new BrokeredStatement40(statementControl, getJDBCLevel()); 263 } catch (SQLException sqle) { 264 notifyException(sqle); 265 throw sqle; 266 } 267 } 268 public final BrokeredPreparedStatement newBrokeredStatement(BrokeredStatementControl statementControl, String sql, Object generatedKeys) throws SQLException { 269 try { 270 return new BrokeredPreparedStatement40(statementControl, getJDBCLevel(), sql, generatedKeys); 271 } catch (SQLException sqle) { 272 notifyException(sqle); 273 throw sqle; 274 } 275 } 276 public final BrokeredCallableStatement newBrokeredStatement(BrokeredStatementControl statementControl, String sql) throws SQLException { 277 try { 278 return new BrokeredCallableStatement40(statementControl, getJDBCLevel(), sql); 279 } catch (SQLException sqle) { 280 notifyException(sqle); 281 throw sqle; 282 } 283 } 284 285 291 public final java.util.Map <String ,Class <?>> getTypeMap() throws SQLException { 292 try { 293 return getRealConnection().getTypeMap(); 294 } catch (SQLException se) { 295 notifyException(se); 296 throw se; 297 } 298 } 299 300 final int getJDBCLevel() { return 4;} 301 302 313 public final boolean isWrapperFor(Class <?> interfaces) throws SQLException { 314 checkIfClosed(); 315 return interfaces.isInstance(this); 316 } 317 318 326 public final <T> T unwrap(java.lang.Class <T> interfaces) 327 throws SQLException { 328 checkIfClosed(); 329 try { 332 return interfaces.cast(this); 333 } catch (ClassCastException cce) { 334 throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP, 335 interfaces); 336 } 337 } 338 } 339 | Popular Tags |